GNU/Linux Command – SORT

sort – Sort lines of text files

Summary :
Sort the file contents based on options given to it. By default the output is showed in the display.

Examples :
$ sort -- Take the input from stdin, sort and output in stdout. $ sort myfile -o myoutput -- Sort the myfile content and storeit in "myoutput". $ sort -b myfile -- Ignore the leading blanks and sort. $ sort -br myfile -- Same as above but in reverse order. $ sort -c myfile -- Only Check whether myfile is already sorted $ sort -f myfile -- Ignore the case and sort (a == A) $ sort -u myfile -- Sort and output only unique lines $ sort -n myfile -- Numerically sort the content. $ sort -g myfile -- Same as above. It understand more complex notations like +, -, NaN, infinity, expo. $ sort -M months -- Month sort (Jan < Feb <..< Dec). $ sort -t : -k 2,2n -k 5.3,5.4 myfile -- Sort numerically on the 2nd field and resolve ties by sorting alphabetically on the 3rdand 4th characters of field 5. Use `:' as the field delimiter.
Read : man sort

Advertisements
Tagged with: ,
Posted in Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: