On 5/3/05, Jacob Meuser <[EMAIL PROTECTED]> wrote: > On Tue, May 03, 2005 at 09:15:19PM -0700, Jason Van Cleve wrote: > > I'd like to process a whole bunch of source files uniformly, stripping > > off any whitespace at the ends of lines and also making sure there is > > exactly one newline before the EOF. That last part may be tricky, but > > is there a speedy *nix utility for getting rid of trailing whitespace, > > or maybe for general source code processing?
if you want speed try sed(1) s/[\w]*$//g #remove any number of white space characters before end of line s/^$//g #remove blank lines followed by echo >> $file #append a blank line to the end of the file. although if you are getting fancy you might want to rewrite it in perl or $language to do manipulation or insertion. having done a fair amount of stuff recently that required mucking about with line end conversions and preprocessing files for a finicky parser this is where find(1) is your friend build your manipulation script and let find pass files to it. (it's also a good idea to make a copy of the target files before you munge them so that you can recover from your mistakes while you are figuring out your regex) _______________________________________________ EUGLUG mailing list [email protected] http://www.euglug.org/mailman/listinfo/euglug
