Add text to beginning of file

Hi
I need to add text to the beginning of a file in the same way that cat will put file contents at the end of a file. I want to do this with many files eg
cat newtext >> /usr/home/*/*.bat

Any ideas?

Something like this

$ ls /usr/home/*/*.bat | while read file; do 
>   ( echo "add this"; cat ${file} ) > ${file}.new && mv ${file}.new ${file}
> done

Cheers,
ZB

sed -i  '1i add here' file*bat
1 Like