In Laymen's Terms
I am reading over a program that was written by a former student, and it has this command:
tr -s ' ' < oldfile | sort -n -k2 > newfile Which takes a data file and puts it in numerical order, according to the values in the second column, from lowest to greatest. I understand the piping feature, but am wondering if anyone can tell me what the meaning is of: tr -s '' and -k2 (I assume this means column 2. Does it mean anything else?) Thanks. |
Quote:
|
The first part says to convert each double instance of a space (the blank space is included in the two single quotes) to a single space. See man tr.
No idea on the second one. |
sort options
The -k2 part means sort by the second field in the line. It sorts starting at the beginning of the 2nd field and continues to the end of the line, if you were to change it to -k2,2, the sort would start at the first character of field 2 and end at the last character of field 2.
The -n option means that the sort is done comparing integers. |
All times are GMT -5. The time now is 06:18 AM. |