Posted By: Anonymous
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.
The short answer:
echo "some data for the file" >> fileName
echo doesn’t deal with end of line characters (EOFs) in an ideal way. So, if you’re gonna append more than one line, do it with
printf "some data for the filenAnd a new line" >> fileName
> operators are very useful for redirecting output of commands, they work with multiple other bash commands.