Saturday, 3 November 2012

sort - Basic Unix Commands


sort

Use this commmand to sort a file. For example, suppose we have a file colors with contents
   red cloth
   green grass
   black sea
   white elephant
   blue whale
   yellow paper

Then we can do this:
  % sort colors
  black sea
  blue whale
  green grass
  red cloth
  yellow paper
  white elephant

To store the output in a file named sortedcolors we do this:
   % sort colors >sortedcolors

No comments:

Post a Comment