Wednesday, October 13, 2010

Sh note: adding a line at the front of files

The example script adds a new line to the beginning of each file in the directory, recursively, except those files that contain svn.

for file in `find . -type f | grep -v 'svn'`;
do
sed '1i\New line' -i $file
done

No comments: