[ic] Removing all instances of "NOT NULL" from an entire
directory of files
Randy Moore
ramoore@axion-it.net
Mon, 11 Sep 2000 19:45:40 -0400
At 04:34 PM 9/11/00 -0700, you 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?
Hi Dan,
The is pretty nasty code, but should work. Warning, you must be in the
directory with the files you are changing for this to work as is.
#!/usr/bin/perl
opendir(DIR, ".");
@filelist = readdir(DIR);
closedir(DIR);
foreach (@filelist) {
system("cat $_ | perl -pi -e \"s/NOT NULL//g\" > $_.new");
system("mv $_ $_.old");
system("mv $_.new $_");
}
Randy Moore
Axion Information Technologies, Inc.
email ramoore@axion-it.net
phone 301-408-1200
fax 301-445-3947