学习python风格, 优雅规范书写shell代码
Word Count
wc -l # line count
Sorts text to STDOUT - original file unchanged
sort [OPTION]... [FILE]...
Options:
-r, --reverse
-n, --numeric-sort
-f, --ingnore-case
-u, --unique
-t "SEP" -k START,END
-o, --output
细节注意:
sort test > test)是没办法将排序好的标准输出重定向到原文件的sort test -o test实例详解:
sort -t":" -k3,3 -rn passwd

sort -uf test

Note: uniq dose not detect repeated lines unless they are adjacent. You may want to sort the input first, or use sort -u without uniq !!

uniq - report or omit repeated lines
常用组合:
sort test | uniq -i

sort test | uniq -c

原文:https://www.cnblogs.com/zakzhu/p/11615435.html