With a little side of applesauce...

Friday, October 8, 2010

BASH - add a new line to the top of a file

This is a fun little sed tip that I found today:
sed -i '1i\<cfabort>' $f

It will add a '<cfabort>' to the first line of a file. Now, we really want to do it to the whole directory of files:
for f in $(ls); do sed -i '1i\<cfabort>' $f ; done 

No comments: