How can I write data to a text file automatically by shell scripting in Linux?
I was able to open the file. However, I don’t know how to write data to it.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The short answer:
However,
echodoesn’t deal with end of line characters (EOFs) in an ideal way. So, if you’re going to append more than one line, do it withprintf:The
>>and>operators are very useful for redirecting output of commands, they work with multiple other bash commands.