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

Re: Finding files not present (challenge to your intelligence)



Eloy A. Paris wrote:
> 
> Hi Martin,
> 
> > How about using find and generate a list of ALL files, then "grep
> > `indivual_lines_from_your_list` list_of_ALL_files" and checking grep's
> > return value?
> 
> Well, what I am doing right now is generating a list of the files that
> are present (using find and redirecting its output to a file). Later,
> I search this file for files not in my original list, so I know which
> files are missing. I am using Perl to do this.
> 

You know, perl is a fine language, it's true. But I think that perl
has made many people think that awk, find, and grep are now "obsolete".
Think again. Heres one solution to your problem: (I'm asssuming that
the list of files is in a file called "searchlist") (WARNING: I'm
sending this with Netscape, and it will probably wrap the lines for
me but this command is all one line--although it needn't be with a
few judicious '\'s)

grep -v $(find / \( $(awk '{if (s != 0) { print " -o " } ; printf 
"-name %s", $1 ; s = 1 }' searchlist ) \) -printf '-e %f\n' )
searchlist

Never doubt the power of bash/grep/awk/find!

-- 
Jens B. Jorgensen
jjorgens@bdsinc.com


Reply to: