简体   繁体   English

如何在Linux中创建包含特定文本的文本文件?

[英]How to create a text file with specific text in it in Linux?

I want to do this with 1 line of code : 我想用1行代码做到这一点:

Create a text file where 3 sentences underneath eachother are placed. 创建一个文本文件,其中放置3个句子。 I know the command to create an empty textfile it is "cat > sample.txt" but i want to create this file with these 3 sentences in it in one line of code. 我知道创建一个空文本文件的命令是“cat> sample.txt”但我想在一行代码中用这3个句子创建这个文件。 Like this : 像这样 :

sentence1
sentence2
sentence3
echo -e "sentence1 \nsentence2 \nsentence3" >> sample.txt

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM