Re: Unix Scripting Question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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;







-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux