[ic] Re: Removing all instances of "NOT NULL" from an entire directory of files

Michael R. Jinks mjinks@uchicago.edu
Mon, 11 Sep 2000 19:04:49 -0500

Try this:

find /path/to/files -type f -exec perl -pi -e "s/NOT NULL//g" {} \;

Check the find(1) manpage for an explanation of the -exec directive.


On Mon, Sep 11, 2000 at 08:02:17PM -0400, rpjday wrote:
> On Mon, 11 Sep 2000, Dan Browning wrote:
> > OK, I've got a command (or two) that will remove all NOT NULL strings from a
> > given file.
> > 
> > 	cat filename | perl -pi -e "s/NOT NULL//g" > filename
> > 
> > But how do I run that command on every file in a directory, successively?
> > 
> whoa, the above perl program does NOT need to have input piped into it.
> all you need to say is:
> $ perl -pi -e "s/NOT NULL//g" file1 file2 file3 ...
>   one at a time, each file argument will be edited *in place*, saved
> back into the original file, and processing moves to the next file.
>   if you want to play it safe, use the option "-pi.BAK" instead, which
> will copy the original file to the name file.BAK (or whatever suffix
> you want) before doing the actual editing.
> rday
> p.s.  warning.  running any command on a file, and trying to redirect
> the new output back to the original file, is a recipe for DISASTER!
> most likely, due to the way redirection works, the file will be wiped
> and you will lose *all* of its contents.
> _______________________________________________
> Redhat-list mailing list
> Redhat-list@redhat.com
> https://listman.redhat.com/mailman/listinfo/redhat-list

Michael Jinks, IB
Systems Administrator, CCCP
finger mjinks@embley.spc.uchicago.edu for public key
Vote Duke! http://www.entertaindom.com/pages/duke2000/home.jsp