【问题标题】:How to remove the leading spaces of the output from the command "uniq"?如何从命令“uniq”中删除输出的前导空格?
【发布时间】:2016-03-27 21:06:09
【问题描述】:
[root@firstcentos scripts]# cat test1
00
00
01
01
00
00
02
02
03
aa
aa
aa
[root@firstcentos scripts]# cat test1 | uniq -c
      2 00
      2 01
      2 00
      2 02
      1 03
      3 aa
[root@firstcentos scripts]# 

【问题讨论】:

    标签: cut cat tr uniq


    【解决方案1】:

    如果要删除前导空格,只需将输出通过管道传输到 sed 即可:

    uniq -c file | sed 's/^\s*//'
    

    例子:

    $ uniq -c file
          2 00
          2 01
          2 00
          2 02
          1 03
          3 aa
    $ uniq -c file | sed 's/^\s*//'
    2 00
    2 01
    2 00
    2 02
    1 03
    3 aa
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-01
      • 2010-10-31
      • 1970-01-01
      • 1970-01-01
      • 2015-08-13
      • 1970-01-01
      相关资源
      最近更新 更多