Prev: micro solution backpack cd-writer hell
Next: "...error while loading shared libraries: libg2c.so.0"
From: blmblm on 12 Dec 2005 03:02 In article <dnj9ca$2iji$1(a)news.uit.no>, Tobias Brox <tobias(a)stud.cs.uit.no> wrote: >[blmblm(a)myrealbox.com] >> Um, different versions of "sort" maybe? The one I use has this option. >> The old syntax, which doesn't seem to be in the man page any more, is >> "sort +0.9" to sort on the 10th position (and following). The newer >> syntax is apparently "sort --key=1.10". FYI, maybe. > >This "key" is intended to be the number of the /column/ one wants to >start with, not what character on the line. Well .... Maybe my example wasn't clear. What I said was that to sort based on characters 10 through end-of-line, one would write "sort --key=1.10". I'm not sure what you mean by "column" here. Quoting from the man page on my system (seems to be for GNU sort): -k, --key=POS1[,POS2] start a key at POS1, end it at POS 2 (origin 1) POS is F[.C][OPTS], where F is the field number and C the character position in the field. OPTS is one or more single-letter ordering options, which override global ordering options for that key. If no key is given, use the entire line as the key. >Say, sorting the >following file by column #2, starting at character #15, is a very easy >thing to do, but "sort" lacks that feature: > >1. this is 6. a space aligned text 9. with three columns >2. just 5. to examplify that sort 8. doesn't handle it well >3. what more 4. can I say? 7. ... > >$ sort --key=15.16 < /tmp/stupid If this is an attempt to sort on characters 15 through something -- I think you don't have the right syntax. The first number is the "field number". I would think from the rest of the man page that this would be related to blank-delimited "fields", but in fact .... I just tried piping the above lines through "sort --key=1.16" and got what I think is the result you want. (16 to account for the ">".) >1. this is 6. a space aligned text 9. with three columns >2. just 5. to examplify that sort 8. doesn't handle it well >3. what more 4. can I say? 7. ... > >I could sort by key #4, though, but it would require a change of the >input: > >$ sort -k 4 < /tmp/stupid >3. what more 4. can I say? 7. ... >2. just to 5. examplify that sort 8. doesn't handle it well >1. this is 6. a space aligned text 9. with three columns "Change of the input"? How so? -- | B. L. Massingill | ObDisclaimer: I don't speak for my employers; they return the favor.
From: Robert M. Riches Jr. on 12 Dec 2005 14:34 On 2005-12-12, Roger Blake <rogblake10(a)iname10.com> wrote: > In article <87pso3oft4.fsf(a)informatik.uni-freiburg.de>, Lee Sau Dan wrote: >> I hate touchpads. They're more difficult to use than trackballs and >> mice. And they're put at the wrong place, making typing difficult. > > I agree. The trouble with trackballs, though, is that they are mechanical > and tend to wear out. Most of the older notebooks I run across have > trackballs that are either dead or flakey. Are you acquainted with the newer optical trackballs? My Logitech Trackman Marble only has one moving part: the ball. There are three contact points I need to clean off every once in a while with a cotton swab, but the sensing is all optical. My oldest one has been in constant use for nearly six years. -- Robert Riches spamtrap42(a)verizon.net (Yes, that is one of my email addresses.)
From: Tobias Brox on 12 Dec 2005 18:55 [blmblm(a)myrealbox.com] >>This "key" is intended to be the number of the /column/ one wants to >>start with, not what character on the line. > Well .... Maybe my example wasn't clear. What I said was that to > sort based on characters 10 through end-of-line, one would write > "sort --key=1.10". I'm not sure what you mean by "column" here. Seems like you are right. > POS is F[.C][OPTS], where F is the field number and C the character > position in the field. OPTS is one or more single-letter ordering > options, which override global ordering options for that key. If no > key is given, use the entire line as the key. I lost that part of the manual. Typical example that a GUI can be better than manual pages, maybe? :-) Without the [.C], one gets what I'd call column (field in the manual), i.e.: $ sort --key=2 /tmp/stupid 24 12332 165345 232213 432223232334 31111 $ sort --key=1 /tmp/stupid 165345 232213 24 12332 432223232334 31111 >>I could sort by key #4, though, but it would require a change of the >>input: >> >>$ sort -k 4 < /tmp/stupid >>3. what more 4. can I say? 7. ... >>2. just to 5. examplify that sort 8. doesn't handle it well >>1. this is 6. a space aligned text 9. with three columns > "Change of the input"? How so? There was a minor change of the /tmp/stupid file from the first example and to the example below - one word was moved, so the first "column" has exactly three words, thus column #4 will be [456]. -- This signature has been virus scanned, and is probably safe to read Tobias Brox, 69?42'N, 18?57'E
From: blmblm on 13 Dec 2005 02:51 In article <dnl2lo$5qn$1(a)news.uit.no>, Tobias Brox <tobias(a)stud.cs.uit.no> wrote: >[blmblm(a)myrealbox.com] >>>This "key" is intended to be the number of the /column/ one wants to >>>start with, not what character on the line. > >> Well .... Maybe my example wasn't clear. What I said was that to >> sort based on characters 10 through end-of-line, one would write >> "sort --key=1.10". I'm not sure what you mean by "column" here. > >Seems like you are right. Sometimes that happens. :-) >> POS is F[.C][OPTS], where F is the field number and C the character >> position in the field. OPTS is one or more single-letter ordering >> options, which override global ordering options for that key. If no >> key is given, use the entire line as the key. > >I lost that part of the manual. Typical example that a GUI can be >better than manual pages, maybe? :-) Depends on whether its structure of menu options and checkboxes is more complete, no? glad you mentioned it, though, since otherwise we'd be off-topic here? [ snip ] >>>I could sort by key #4, though, but it would require a change of the >>>input: >>> >>>$ sort -k 4 < /tmp/stupid >>>3. what more 4. can I say? 7. ... >>>2. just to 5. examplify that sort 8. doesn't handle it well >>>1. this is 6. a space aligned text 9. with three columns > >> "Change of the input"? How so? > >There was a minor change of the /tmp/stupid file from the first >example and to the example below - one word was moved, so the first >"column" has exactly three words, thus column #4 will be [456]. Got it -- though rather than "change" I'd say "major restriction" (first "column" of text has to be exactly two words). This seems to be a case in which sorting on blank-delimited fields (a.k.a columns) doesn't work well. I'm not sure how any sort utility would do better. What you want is to sort based on a range of character positions, as you said. Fortunately that does seem to be possible. Maybe in addition to the syntax mentioned earlier it would be smart to use "--field-separator=SEP" to indicate that something other than blanks separates fields, so each line appears to be just one field -- though it seems that examples work without that. -- | B. L. Massingill | ObDisclaimer: I don't speak for my employers; they return the favor.
From: Tobias Brox on 13 Dec 2005 23:38
[blmblm(a)myrealbox.com] >>I lost that part of the manual. Typical example that a GUI can be >>better than manual pages, maybe? :-) > Depends on whether its structure of menu options and checkboxes is > more complete, no? Right, besides a feature hidden far down in some menu hierarchy is by no means better than a CLI feature that is hidden in the "wrong" part of the manual. > I'm not sure how any sort > utility would do better. What you want is to sort based on a range > of character positions, as you said. Eventually a "smart" utility that would first scan through the data to find likely column positions - but, after all, this format is particularly suited for human readers not for machine processing. It would probably be better to choose another data format. I had actually expected somebody to jump up and tell that it would be better to use "find ... -printf ..." instead of "find ... -ls" |