一道shell排序题说明sort -r和sort -nr区别

[root@pangu icai]# cat  words.txt
how many cans can a canner can if a canner can can cans
a canner can can as many cans as a canner can if a canner can can a can
a canner can can as many cans as a canner can cans

[root@pangu icai]# cat words.txt |tr  ' '  '\n'|sort |uniq -c|sort -r
      8 a
      7 canner
      5 cans
      4 as
      3 many
      2 if
      1 how
     13 can
[root@pangu icai]# cat words.txt |tr  ' '  '\n'|sort |uniq -c|sort -nr
     13 can
      8 a
      7 canner
      5 cans
      4 as
      3 many
      2 if
      1 how

关于解题:
https://discuss.leetcode.com/topic/87252/solve-this-problem-in-linux-style

    原文作者:国才大叔的小屋
    原文地址: https://www.jianshu.com/p/291632a11ede
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞