使用 Shell 命令将多行文本输出到文件非常简单,您可以使用重定向符号 (>) 并将其与多行文本一起使用。

以下是一个示例:

cat << EOF > output.txt
This is the first line of the file.
This is the second line of the file.
And this is the third line of the file.
EOF

在这个示例中,我们使用 cat 命令和 << 符号来指示 Shell 我们将输入多行文本。然后,我们将文本的结束标记 EOF 与重定向符号和输出文件名 output.txt 一起使用,以将文本输出到文件中。

当您运行此命令时,Shell 将创建一个名为 output.txt 的新文件,并将三行文本写入该文件。

Shell: 如何将多行文本输出到文件

原文地址: https://www.cveoy.top/t/topic/lNxf 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录