我使用 uniq -c 一些文本文件。它的输出是这样的:
123(space)first word(tab)other things
2(space)second word(tab)other things
……
所以我需要提取总数(比如上面的 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