How to append string/data to a file in Linux
This article will show you how to append a string (or any data) to the end of a file under Linux/Unix. Appending is done very simply by using the append redirect operator >>. Simply use the operator in the format data_to_append >> filename and you’re done. Below are several examples:
Examples to Append Data to a File
- To append the string “hello” to file greetings.txt
- To append the contents of the file temp.txt to file data.txt
- To append the current date/time timestamp to the file dates.txt
echo "hello" >> greetings.txt
cat temp.txt >> data.txt
date >> dates.txt
was helpful
Thanks a lot!
realy helpful, thanks!
Thank you, it helped me a lot.
how can add the data to the file without open the file in UNIX/Linux ?
Great article!
Thanks
Thanks, ’twas helpful !!