Find missing files from a list

 counter=0;
while read line;
 do [[ -e "$line" ]] && let  counter=counter+1; done < input_file.txt
echo $counter

The above code is reading a file line by line and checking whether the filenames mentioned in the file exist or not .
At present the o/p is value of counter

I want to echo out the name of files not found ( ie present on input file.txt but not in search directory )

eg : if input_file.txt contains files a , b , c
and c is not there in search directory . I want to echo out C not found .

Pls advise ..

Try this..

ls <serach directory> | grep -vf input_file.txt

---------- Post updated at 12:57 PM ---------- Previous update was at 12:50 PM ----------

IF thats not working, try with this.. Bcoz I dont find -f option works with grep in Solaris

ls . | grep -v `cat input_file.txt`
cat filename | xargs ls

will automatically use the ls error message to print "No such file or directory"

Hey thanks 4 ur respomse

bt how do i implement those in the above script ..
running short of ideas

Pls suggest

echo `cat filename | xargs ls`

Also try,

do [[ -e "$line" ]] && let  counter=counter+1  || echo "$line not found" ; done < input_file.txt
1 Like