mardi 24 mars 2015

How to put a newline special character into a file using the echo command and redirection operator?


I would like to create a file by using the echo command and the redirection operator, the file should be made of a few lines.


I tried to include a newline by "\n" inside the string:



echo "first line\nsecond line\nthirdline\n" > foo


but this way no file with three lines is created but a file with only one line and the verbatim content of the string.


How can I create using only this command a file with several lines ?



Aucun commentaire:

Enregistrer un commentaire