通过cat + EOF命令在文件末尾的追加内容
使用cat
和EOF
在文件末尾追加内容时,应当使用追加重定向符号>>
而不是>
。下面是一个示例:
cat >> existing_file.txt << 'EOF'
line to be appended
another line to append
...
EOF
执行上述命令后,从<< 'EOF'
开始直到遇到第一个EOF
为止的所有文本将被追加到existing_file.txt
文件的末尾。
例如:
cat >> example.txt << 'EOF'
Appended content starts here.
This will be on a new line.
And this too.
EOF
执行这段命令后,example.txt
中原有的内容会保持不变,并在末尾增加新的内容:
...(假设已有内容)
Appended content starts here.
This will be on a new line.
And this too.
原文地址:https://blog.csdn.net/weixin_42494218/article/details/136361270
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!