In the Linux command, the sort command can be used to sort the file lines. Many people don't know the sort command very well. The following small series will give a brief introduction to the example of the sort command. Friends who are not familiar with the sort command can understand under.
sort command is regarded as a plurality of domains each line of text, by default, in a space between domain or a series of spaces delimiter, the delimiter may further specify the -t option. Sort left to right by the ASCII value of the character (not the value).
1, remove duplicates: remove the same line in the file
sort -u filename
2, reverse ordering
sort –r filename
3, use k option to classify
The format of the command is:
sort -k [ FStart [ .CStart ] ] [ Modifier ] [ , [ FEnd [ .CEnd ] ][ Modifier ] ]
FStart.CStart, where FStart is the field used, and CStart means that the first character in the FStart field is “sorted first character”, similarly FEnd .Cend. However, if Cstart is omitted, it is the domain header, Cend is omitted, it is the domain tail, and if FEnd is omitted, it is the trailing edge. Modifier has the following important things: n, interpreting text as a numerical value; r, sorting in reverse order; f, ignoring case. Of course you can specify two k options, which will be parsed by rule. For example:
sort -n -k 2.2,3.1 -k 1,1r facebook.txt
The above is the way Linux uses the sort command, the sort command can remove the same line in the file. Sorting in reverse order, using k option classification, of course, there are many usages of the sort command, you need to use it flexibly.
Linux system administrators need to perform real-time monitoring of commands so tha
The Linux disk has failed, causing the system to run slowly. If it is a personal ok
When doing a Java website project, if you encounter a problem that the Tomcat serve
In Linux systems, route forwarding refers to a protocol in which signals are transf
How does the Linux system send mail?
How to solve the problem after unable to connect to the network after reinstalling Linux
How to use the cat command under Linux?
Two ways to speed up the copying speed of Linux files
Linux mint how to solve the problem of no sound in the root login
What should I do if libpng fails to compile after Gentoo upgrade?
How to use sudo command in Linux system?
Usage of Linux global variable jiffies
What should I do if there is garbled code on the Firefox browser page under Linux?
What can I do if RedHat Linux 5 cannot use ifconfig?
Win7 right-click menu to add "Open with Notepad" option tutorial
Microsoft will offer 90 days of free use of Office 365 services
How to do computer memory shortage win7 memory is not enough how to do
System acceleration Starting from the gradual optimization of the XP system (7)
Win7 system computer disk abnormally can not open C disk, D disk how to do
Close Win7 system transparent effect process Practical method
Linux server modify .htaccess file to achieve 301 redirect
What should I do if the win7 input method icon is missing?