Monday, December 15, 2008

append newline at end of files

Frequently when you download source code off the internet and try to compile, you end up getting a bunch of "warning: no newline at end of file" . to append a newline at the end of each *.c and *.h files use the following one liner.


find ./ \( -name "*.h" -o -name "*.cpp" \) -exec perl -i.bak -lpe 'print "\n" if eof' {} \;


ps: the space between the '{}' and '\;' at the end is required and there is no space in between "\;". else the follwing error occurs

find: missing argument to `-exec'

No comments: