相关疑难解决方法(0)

为什么uniq -c输出空格而不是\ t?

我使用uniq -c一些文本文件.它的输出如下:

123(space)first word(tab)other things
  2(space)second word(tab)other things
Run Code Online (Sandbox Code Playgroud)

....

所以我需要提取总数(如上面的123和2),但我无法弄清楚如何,因为如果我按空格分割这一行,它会喜欢这个['123', 'first', 'word(tab)other', 'things'].我想知道它为什么不用标签输出?

以及如何提取shell中的总数?(我终于用python,WTF提取它)

更新:对不起,我没有正确描述我的问题.我不想总和总数,我只想用(制表符)替换(空格),但它不影响单词中的空格,因为我之后仍然需要数据.像这样:

123(tab)first word(tab)other things
  2(tab)second word(tab)other things
Run Code Online (Sandbox Code Playgroud)

shell awk uniq

5
推荐指数
2
解决办法
5636
查看次数

标签 统计

awk ×1

shell ×1

uniq ×1