【发布时间】:2020-05-22 22:49:06
【问题描述】:
我有三个单行文本文件 foo1.txt、foo2.txt 和 foo3.txt。在我使用 cat foo1.txt foo2.txt foo3.txt > foo.txt 之后,foo.txt 包含三行我不想要的,我想要从每个文件中加入一行。
我试过cat foo.txt | sed 's/\n//g' > new.txt,但 new.txt 与 foo.txt 相同。
我试过tr '\n' '' < foo.txt > new.txt,一样,new.txt和foo.txt一样。
我试过paste -sd "\0" foo1.txt foo2.txt foo3.txt > foo.txt,但 foo.txt 仍然包含三行。
我试过echo $(cat foo1.txt foo2.txt foo3.txt) > foo.txt,虽然 foo.txt 包含一行,但是所有的空格都没有了。
有什么建议吗?
【问题讨论】:
标签: unix