#!/bin/sh find "$DEV" -name '*.cpp' -o -name '*.h' -o -name '*.c' | \ perl -lne'sysopen(Z,$_,0) && sysseek(Z,-1,2) && sysread(Z,$c,1) && close(Z) or warn("$_: $!\n"),next;$c eq "\n" or s/ /\\ /g,print' | \ xargs perl -i -lpe'eof && warn "Fixed $ARGV\n"' #### #!/bin/sh perl -MFile::Find -le'find({no_chdir=>1, wanted=>sub{/\.c(?:pp)?$/||/\.h$/ or return;sysopen(Z,$_,0) && sysseek(Z,-1,2) && sysread(Z,$c,1) && close(Z) or warn("$_: $!\n"),return;$c eq "\n" or push@f,$_}},$ENV{DEV});@f||exit;@ARGV=@f;$^I="";while(<>){chomp;print;eof && warn "Fixed $ARGV\n"}'