On Mar 26, Eloy A. Paris wrote : Hi, : : I was given a text file containing one file name (no full path name) : per line. My task consists of searching the entire filesystem and : generate a list of the files that are NOT present. 1. The perl solution: ------------------------------- #!/usr/bin/perl # * probably overkill, if your file list # is rather short. # * probably storing the existing files in a @Array # and grepping is faster # * probably a shell line with sort / uniq / comm would # do the same job # generate a list of existing files open(IN, "find . -type f -printf \"%f\n\"|") or die; while(<IN>) { chomp; $Files{$_} = 1; } # read in the search list and see, the file exists open(IN, "searchlist") or die; while (<IN>) { chomp; $Files{$_} or print "Missing: $_\n"; } 2. The Shell solution -------------------------------- find -type f -printf "%f\n" | sort > files.exist sort < searchlist > files.search comm -1 -3 files.exist files.search Heiko Schlittermann --------------------------------------------- Heiko Schlittermann / Internet & Unix-Support Kamenzer Str. 52 D-01099 Dresden Voice: +49-172-7909055 Mail: heiko@sax.de
Attachment:
pgpj69cQZzuUq.pgp
Description: PGP signature