Latest web development tutorials

Linux sort command

Linux command Daquan Linux command Daquan

Linux sort command to sort the contents of a text file.

You can sort for the content of text files, in units ordered.

grammar

sort [-bcdfimMnr][-o<输出文件>][-t<分隔字符>][+<起始栏位>-<结束栏位>][--help][--verison][文件]

Parameter Description:

  • -b Ignore front row start of each space character.
  • -c Check whether the file has been sorted in the order.
  • -d sorting, handling letters, numbers and space characters, the other characters are ignored.
  • -f sort, lowercase letters are considered to uppercase.
  • -i sort, in addition to ASCII characters between 040-176, and ignore the other characters.
  • -m to merge several files sorted.
  • -M In accordance with the preceding three-letter month abbreviation to be sorted.
  • -n value in accordance with the size of the order.
  • -o <output file> results sorted into the specified file.
  • -r sort in reverse order.
  • -t <separator characters> Specifies the sort used in the field separator character.
  • + <Start column> - <end column> to specify the field to sort, by the scope of the starting field to the end of the field before a field.
  • --help displays help.
  • --version display version information.

Examples

Using the sort command to the default file type for the row sort order are as follows:

sort testfile 

sort command will default way to the first column of the order of the ASCII text file and output the results to standard output.

Use the cat testfile command to display the original document seen its ranking as follows:

$ cat testfile      #testfile文件原有排序  
test 30  
Hello 95  
Linux 85 

Using the sort command results rearranged as follows:

$ sort testfile #重排结果  
Hello 95  
Linux 85  
test 30 

Linux command Daquan Linux command Daquan