I have a folder full of text files. I need to append the same block of text to each of them (and of course overwrite the original file).
I was wondering what the co
very simply one which worked well for me
#!/bin/sh
FILES="./files/*"
for f in $FILES
do
echo '0000000' | cat - $f > temp && mv temp $f
done
If you're needing to do this via a script, you can use echo and append redirection to get the extra text into the files.
FILES=pathto/*
for f in $FILES ; do
echo "#extra text" >> $f
done
Use append redirection.
for f in *.txt
do
cat footer >> "$f"
done
Variant of kurumi's answer:
sed -i.bak "\$aTEXTTOINSERT" *.txt
For more details, see SED: insert something to the last line?
sed -i.bak "$ a $(<file_block_of_text)" *.txt