美文网首页ShellShell那些事儿shell
一道shell排序题说明sort -r和sort -nr区别

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

作者: 国才大叔的小屋 | 来源:发表于2017-04-23 14:41 被阅读45次
    [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

    相关文章

      网友评论

        本文标题:一道shell排序题说明sort -r和sort -nr区别

        本文链接:https://www.haomeiwen.com/subject/xehyzttx.html