[ic] Re: Removing all instances of "NOT NULL" from an entire directory
of files
rpjday
rpjday@mindspring.com
Mon, 11 Sep 2000 20:02:17 -0400 (EDT)
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.