新聞中心
SORT command is the most commonly used command for sorting files in linux. It is a command line utility that can be used to sort files according to various criteria, like alphabetically, numerically and chronologically.

成都創(chuàng)新互聯(lián)為您提適合企業(yè)的網(wǎng)站設(shè)計?讓您的網(wǎng)站在搜索引擎具有高度排名,讓您的網(wǎng)站具備超強的網(wǎng)絡(luò)競爭力!結(jié)合企業(yè)自身,進行網(wǎng)站設(shè)計及把握,最后結(jié)合企業(yè)文化和具體宗旨等,才能創(chuàng)作出一份性化解決方案。從網(wǎng)站策劃到成都網(wǎng)站設(shè)計、網(wǎng)站制作, 我們的網(wǎng)頁設(shè)計師為您提供的解決方案。
Sort command provides many options/flags to sort files in different manners. It also accepts options to sort in reverse order, to ignore differences between folded and upper/lower cases and to discard empty lines.
Example 1:
Sort Alphabetically
The below example shows how to sort a file containing a list of words in alphabetic order.
$sort words.txt
apple
banana
cat
dog
Example 2:
Sort Numerically
The below example shows how to sort a file containing a list of numbers in a numerical order.
$sort -n numbers.txt
1
2
3
4
Example 3:
Sort in Reverse order
The below example shows how to sort a file containing a list of words in reverse alphabetical order.
$sort -r words.txt
dog
cat
banana
apple
Example 4:
Ignore Case differences
The below example shows how to sort a file containing a list of words ignoring their case differences.
$sort -f words.txt
apple
banana
Cat
dog
Example 5:
Discard empty lines
The below example shows how to sort a file containing a list of words and dropping empty lines in the output.
$sort -z words.txt
apple
banana
cat
dog
In conclusion, the sort command is a useful utility to arrange files in Linux according to various criteria. It provides many options which can be used to sort files with different conditions and produce expected result. With the help of these examples, you can easily understand more about sorting files using this command.
成都網(wǎng)站建設(shè)選創(chuàng)新互聯(lián)(?:028-86922220),專業(yè)從事成都網(wǎng)站制作設(shè)計,高端小程序APP定制開發(fā),成都網(wǎng)絡(luò)營銷推廣等一站式服務(wù)。
當(dāng)前文章:深入了解Linux命令中的排序方法(linux命令排序)
轉(zhuǎn)載注明:http://m.5511xx.com/article/dhhecje.html


咨詢
建站咨詢
