Cupp Michael E Contr AFRL/DIB said: > I have a file (a.lst) that has a list of fully pathed filenames, 1 per > line - in this format: > > "/path/to/the/name_of_file.doc" > "/path/to/the/other/name of the doc noting spaces.doc" > > I need to know how I can loop through this file, a.lst, and for each > entry, perform a test -s on it. If it exists, I want to put the entry > into exists.txt, if it does not, I want to put the entry in noexist.txt > - > > Can someone please help me? (I've tried for foo in `cat a.lst`, but due > to the spaces in 90% of the filenames, it pukes, as it appears to be > using space as the delimiter) > > > Thanks again, > Michael Here's a quick Perl script that I put together that will do what your asking.... #!/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; Chris Purcell, RHCE > -- redhat-list mailing list unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe https://www.redhat.com/mailman/listinfo/redhat-list