I am trying to sort a file called data for learning purposes. Its given in my textbook.
5 27
2 12
3 33
23 2
-5 11
15 6
14 -9
Q1) What is the order of just sort data in this case ?
Q2) I am working in one folder. sort data works, but sort +1n data does not. Why ?
I typed it exactly like in the book and I get this error -
sort: cannot read: +1n: No such file or directory
EDIT - The book wants to skip column 1 and sort by column 2. Thats why +n might be used.
I use lubuntu 13 to learn unix bash scripting.
PS - Here is the output of sort data
14 -9
15 6
2 12
23 2
3 33
-5 11
5 27
-k, to define key ranges. Note they are ranges! Not columns!sort, but the number before the comma is the start column, and the number after is the end column. Usingsort -k1 datais the same assort dataand means sort by column 1, then by column 2, then by column 3, ... You can also usesort -k1.2 datawhich sorts starting with the second character in column 1, etc. Note that on any specific system, including Linux in particular, thesortcommand often has options not defined by POSIX.