Unix Scripting Question
Chris Purcell
redhat at cjp.us
Tue May 4 14:49:41 UTC 2004
fyi, the formatting got a little messed up while copying and pasting, I
fixed it below....
>
>
>
#!/usr/bin/perl
$a = '/root/a.1st';
open(FILE, $a) or die "Can't open file: $!\n";
@lines = <FILE>;
close FILE;
$exists = '/root/exists.txt';
open(EXISTS, ">$exists") or die "Couldn't open exists.txt for writing: $!\n";
$nonexist = '/root/nonexist.txt';
open(NONEXIST, ">$nonexist") or die "Couldn't open nonexists.txt for
writing: $!\n";
foreach (@lines) {
$_ =~ s/"//g;
chomp;
if (-e $_) {
print "$_ exists\n";
print EXISTS "$_\n";
} else {
print "$_ doesn't exist\n";
print NONEXIST "$_\n";
}
}
close EXISTS;
close NONEXISTS;
More information about the redhat-list
mailing list