[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
confusion with sort
From: |
Mickey Ferguson |
Subject: |
confusion with sort |
Date: |
Wed, 2 Apr 2008 12:56:06 -0700 |
On a Windows XP SP2 system, using a reasonably recent port of GNU sort (and
not the sort.exe that comes in the System32 folder on a windows system), I
am not figuring out how to restrict my sorting fields properly. I've got a
text file where I only want to sort the file based on the first 12
characters of the line (which happens to be a time stamp), and then ignore
the rest of the line. Here is my test input file:
16:58:35.832 DmsSP.exe(3.2.0.30) DmsApp::initConfiguration : {5692}
16:58:35.832 DmsSP.exe(3.2.0.30) DmsApp::initUI : {5692}
16:58:35.832 DmsSP.exe(3.2.0.30) DmsApp::initVFXServices : {5692}
16:58:35.957 DmsSP.exe(3.2.0.30) DmsApp::sendStartupState : {5692} Entering
16:58:35.957 DmsSP.exe(3.2.0.30) DmsApp::setStartupState : {5692} Entering
16:58:35.957 LineMngrC.exe(3.1.0.12) CVolumeManager : Adjusting caller
playback to 50 for LOG_DEBUG (1).
16:58:35.957 DmsSP.exe(3.2.0.30) ALARM<Informational> - Initializing
DMS-100 service provider.
16:58:36.222 LineMngrC.exe(3.1.0.12) CMainDlg : Driver type is Standard -
DMS-100
16:58:36.457 LineMngrC.exe(3.1.0.12) CLineManager : Physical line # 8998,
Type: 32
16:58:36.457 LineMngrC.exe(3.1.0.12) CLineManager : Physical line # 8999,
Type: 28
16:58:36.410 LineMngrC.exe(3.1.0.12) CLineManager : FillPhysicalLineTpes
16:58:36.441 LineMngrC.exe(3.1.0.12) CLineManager : Physical line # 1, Type:
2
16:58:36.457 LineMngrC.exe(3.1.0.12) CLineManager : Physical line # 9998,
Type: 32
16:58:36.457 LineMngrC.exe(3.1.0.12) CLineManager : Physical line # 9999,
Type: 28
16:58:36.457 LineMngrC.exe(3.1.0.12) CLineManager : Physical line # 2501200,
Type: 34
16:58:36.457 LineMngrC.exe(3.1.0.12) CLineManager : Physical line # 2501201,
Type: 34
16:58:36.472 LineMngrC.exe(3.1.0.12) CLineManager : Physical line # 2501202,
Type: 34
There is a tab character between the thousandths of a second and the
filename, and another tab character between the file version and the next
string, except for the line with "ALARM..." on it, where there are two tabs
between the file version and ALARM.
After sorting, it should look like this:
16:58:35.832 DmsSP.exe(3.2.0.30) DmsApp::initConfiguration : {5692}
16:58:35.832 DmsSP.exe(3.2.0.30) DmsApp::initUI : {5692}
16:58:35.832 DmsSP.exe(3.2.0.30) DmsApp::initVFXServices : {5692}
16:58:35.957 DmsSP.exe(3.2.0.30) DmsApp::sendStartupState : {5692} Entering
16:58:35.957 DmsSP.exe(3.2.0.30) DmsApp::setStartupState : {5692} Entering
16:58:35.957 LineMngrC.exe(3.1.0.12) CVolumeManager : Adjusting caller
playback to 50 for LOG_DEBUG (1).
16:58:35.957 DmsSP.exe(3.2.0.30) ALARM<Informational> - Initializing
DMS-100 service provider.
16:58:36.222 LineMngrC.exe(3.1.0.12) CMainDlg : Driver type is Standard -
DMS-100
16:58:36.410 LineMngrC.exe(3.1.0.12) CLineManager : FillPhysicalLineTpes
16:58:36.441 LineMngrC.exe(3.1.0.12) CLineManager : Physical line # 1, Type:
2
16:58:36.457 LineMngrC.exe(3.1.0.12) CLineManager : Physical line # 8998,
Type: 32
16:58:36.457 LineMngrC.exe(3.1.0.12) CLineManager : Physical line # 8999,
Type: 28
16:58:36.457 LineMngrC.exe(3.1.0.12) CLineManager : Physical line # 9998,
Type: 32
16:58:36.457 LineMngrC.exe(3.1.0.12) CLineManager : Physical line # 9999,
Type: 28
16:58:36.457 LineMngrC.exe(3.1.0.12) CLineManager : Physical line # 2501200,
Type: 34
16:58:36.457 LineMngrC.exe(3.1.0.12) CLineManager : Physical line # 2501201,
Type: 34
16:58:36.472 LineMngrC.exe(3.1.0.12) CLineManager : Physical line # 2501202,
Type: 34
The sort command I thought I should use is: sort -k 1,1.12 test.log. Here
is what I get:
16:58:35.832 DmsSP.exe(3.2.0.30) DmsApp::initConfiguration : {5692}
16:58:35.832 DmsSP.exe(3.2.0.30) DmsApp::initUI : {5692}
16:58:35.832 DmsSP.exe(3.2.0.30) DmsApp::initVFXServices : {5692}
16:58:35.957 DmsSP.exe(3.2.0.30) ALARM<Informational> -
Initializing DMS-100 service provider.
16:58:35.957 DmsSP.exe(3.2.0.30) DmsApp::sendStartupState : {5692}
Entering
16:58:35.957 DmsSP.exe(3.2.0.30) DmsApp::setStartupState : {5692}
Entering
16:58:35.957 LineMngrC.exe(3.1.0.12) CVolumeManager : Adjusting caller
playback to 50 for LOG_DEBUG (1).
16:58:36.222 LineMngrC.exe(3.1.0.12) CMainDlg : Driver type is Standard -
DMS-100
16:58:36.410 LineMngrC.exe(3.1.0.12) CLineManager : FillPhysicalLineTpes
16:58:36.441 LineMngrC.exe(3.1.0.12) CLineManager : Physical line # 1,
Type: 2
16:58:36.457 LineMngrC.exe(3.1.0.12) CLineManager : Physical line #
2501200, Type: 34
16:58:36.457 LineMngrC.exe(3.1.0.12) CLineManager : Physical line #
2501201, Type: 34
16:58:36.457 LineMngrC.exe(3.1.0.12) CLineManager : Physical line # 8998,
Type: 32
16:58:36.457 LineMngrC.exe(3.1.0.12) CLineManager : Physical line # 8999,
Type: 28
16:58:36.457 LineMngrC.exe(3.1.0.12) CLineManager : Physical line # 9998,
Type: 32
16:58:36.457 LineMngrC.exe(3.1.0.12) CLineManager : Physical line # 9999,
Type: 28
16:58:36.472 LineMngrC.exe(3.1.0.12) CLineManager : Physical line #
2501202, Type: 34
Notice the subtle difference: The lines at .957 are not in the same order
as in the original file. Apparently my sort is just sorting the entire
line, instead of limiting the sort determination to the first twelve
characters. What am I doing wrong?
- confusion with sort,
Mickey Ferguson <=