Ask Your Question
4

How to add text to a new line in a file using a Bash script?

asked 2021-10-04 11:00:00 +0000

huitzilopochtli gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2021-08-05 03:00:00 +0000

lalupa gravatar image

To add text to a new line in a file using a Bash script, you can use the following command:

echo "new line text" >> file.txt

This will append the text "new line text" to the end of the file on a new line. The >> symbol tells Bash to append the text rather than overwrite the file, and the echo command outputs the text to the console, which is then redirected to the file using the >> symbol.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-10-04 11:00:00 +0000

Seen: 16 times

Last updated: Aug 05 '21