• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

friggin' "sort" command... I cant understand this damn thing

xyyz

Diamond Member

i have been trying to understand this chapter titled "Searching for Files and Text" for a few weeks now.

unfortunately, this chapter is one of those things, that no matter how hard you try and how long you try for, you are incapable of understanding (at least in my case)

this entire chapter, grep and it's derivatives and the sort command have been extremely frustrating.

i am hung up on the sort command more so than the others, but there are certain features that are especially difficult to understand.

this is what the book says about the sort command:

sort -options filenames(s)

the following two options are killing me:

-n performs a numeric sort.
(+|-)n begins (+n) or ends (-n) the sort with the field following the n
field

consider the following two examples, that have 8 columns (do columns=fields ?):

sort -rn +4 list -o num.list
sort -rn -3 list -o num2.list
sort +5n list -o update.list

first i would like some clarification with the (+|-)n option.

in the first example, the +4 says that we start counting from the 5th field (5th field because we start counting from 0, not 1 right?)... so when we count, we use fields 5,6,7 right?

in the second example, the -3 says we start counting from the 4th field backwards right? so 3,2,1,0?

next, i'm confused with what I see with the first two examples and the last. I notice that in the first two examples the +/- numbers (+4 and -3) are isolated options, but in the last example, +5n, the two options I mentioned earlier are combined. I don't understand why this is done, or what it means. shouldn't it be +5 -n instead of +5n? is +5 -n different from +5n?

can anyone please help reduce my confusion with this command?
 

bump....

comeon... we have to have someone here who actually knows a thing or two about unix commands...

monkey... you wanna take this one?
 
Back
Top