Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

linux

ubuntu

cat

I want to do this with 1 line of code :

Create a text file where 3 sentences underneath eachother are placed. 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. Like this :

sentence1
sentence2
sentence3
like image 367
Jim Peeters Avatar asked Oct 17 '25 18:10

Jim Peeters


1 Answers

echo -e "sentence1 \nsentence2 \nsentence3" >> sample.txt
like image 66
haxtbh Avatar answered Oct 20 '25 08:10

haxtbh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!