相关疑难解决方法(0)

如何将多行附加到文件

我正在编写一个 bash 脚本来查找不存在的文件,然后创建它并将其附加到它:

Host localhost
    ForwardAgent yes
Run Code Online (Sandbox Code Playgroud)

所以"line then new line 'tab' then text"我认为它是一种敏感的格式。我知道你可以这样做:

cat temp.txt >> data.txt
Run Code Online (Sandbox Code Playgroud)

但它看起来很奇怪,因为它有两行。有没有办法以这种格式附加它:

echo "hello" >> greetings.txt
Run Code Online (Sandbox Code Playgroud)

shell io-redirection text-processing

460
推荐指数
6
解决办法
103万
查看次数

标签 统计

io-redirection ×1

shell ×1

text-processing ×1