add text to end of text file

Hi,

I assume there is a simple solution, but as usual i can't find it!
How can i add a line of text to the end of a text file on a new line?

i.e
file.txt
________________
this is my text file
________________

file.txt
________________
this is my text file
WITH A NEW LINE
________________

Thanks for your time

Lee

1 Like

LeeRoberts,
Here is one way of doing this:

(cat input_file ; echo "WITH A NEW LINE") > output_file
1 Like
echo "WITH A NEW LINE" >> file
1 Like

thanks, and how about something at the start of a text file?

1 Like
sed '1i yourline' file
1 Like
cat file | awk �BEGIN {print �This is my first line�} {print $0}' > file

UUOC

awk 'BEGIN {print "This is my first line"}{print $0}' file > file3322