tags:

views:

85

answers:

4

how to append text line after the last line in file without using echo command need example in sed and awk THX yael

+1  A: 
echo "Append this line" >> file.txt
Sjoerd
+1  A: 

Here's how you do it without sed:

echo "Hello World" >> file.txt

Here's how you do it with sed:

sed -i '$aHello World' file.txt
tylerl
I cant use the echodid you have example in awk?
yael
+1  A: 

It's pretty easy to add lines with awk by using the END matcher:

awk '{print}END{print "another line"}' input_file
paxdiablo
+3  A: 

Without using echo:

awk 'BEGIN {print "line of text"}' >> file.txt

printf "line of text\n" >> file.txt

cat <<< "line of text" >> file.txt

cat <<EOF >> file.txt
line of text
EOF

head -c 1 /dev/zero | sed 's/./line of text\n/' >> file.txt

read -p $'line of text\n' -t .00012 2>> file.txt
Dennis Williamson
+1 for being comprehensive. Painfully comprehensive. Almost anal :-)
paxdiablo
@paxdiablo: Shoot! I was going for "sarcastic".
Dennis Williamson
Sarcastic, oh my, yes. Drippingly.
Beta