unix sort


You want to perform a sort:

… But ignore leading blanks;
… Perform numerical sort;
… Offset it to the third column;
… Reverse it;



As always with UNIX we supply the arguments, with letters.

See the example tag.



8 flags to the UNIX sort command.

1) -b # ignores leading blanks.

2) -f # ignore case

3) -n # numerical

4) -r # reverse

5) –key=pos# # sort by key or +# in Solaris, etc take note of -t though for field separator

6) -o # output to file, useful for doing a sort -o fileA fileA – rather than redirect than can overwrite.

7) -u # strip unique lines. You can also use the uniq command, which includes a -c option to count repeating lines.

8) -i # ignore non-printable chars



[tags]UNIX Sort, UNIX, sort, UNIX Coding School[/tags]


If you have found my website useful, please consider buying me a coffee below 😉

Leave a Reply

Your email address will not be published. Required fields are marked *