我有 70mb .tsv 文件,我想从每行删除“/”并使用 sed 或 tr 或任何基于 Linux 的命令添加空格而不是“/”[已关闭]

问题描述 投票:0回答:2

我想从每行中删除“/”并添加空格而不是“/”

输入示例:

7 47562385 47562385 ctttttttttttttttt/cttttttttttttttt

11 48932150 48932150 C/A

6 87733066 87733066 caaaaaaaaaaaaaaaaaaaaaa/cAAaaaaaaaaaaaaaaaaaaaaaa

8 4056078 4056078 cttttttttttttttttttttt/cTTttttttttttttttttttttt

我想要这样的输出

7 47562385 47562385 ctttttttttttttttt cttttttttttttttt

1 48932150 48932150 C A

6 87733066 87733066 caaaaaaaaaaaaaaaaaaaaaa cAAaaaaaaaaaaaaaaaaaaaaaa

8 4056078 4056078 cttttttttttttttttttttt cTTttttttttttttttttttttt
linux sed grep command tr
2个回答
0
投票

您可以使用 grep 和 sed 的组合来将输入文件的每一行中所有出现的 / 替换为空格。

grep . input.txt | sed 's/\// /g

如果要将输出保存到新文件,可以重定向输出:

grep . input.txt | sed 's/\// /g' > output.txt


-1
投票

通常你可以只使用查找和替换,但如果你的场景不同,你需要以更详细的方式说明。

© www.soinside.com 2019 - 2024. All rights reserved.