我使用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)