Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux技術

LINUX sort 命令用法

sort 是用來對文字內容排序的指令。以下示範對 test 檔案的各種排序方式:

[code]cat test:
LINUX sort 命令用法

cat test | sort:按第一個字元排序。

LINUX sort 命令用法

cat test | sort -r(reverse):降序排序。

LINUX sort 命令用法

cat test | sort -t ":" -k 2:以「:」為分隔符,取出第二個欄位來排序。

LINUX sort 命令用法

cat test | sort -n:按數值大小排序。

cat test | sort -u:去掉重複行(unique 命令也能去掉重複行)。

Copyright © Linux教程網 All Rights Reserved