Find missing files from a list


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find missing files from a list
# 1  
Old 08-10-2010
Bug Find missing files from a list

Code:
 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 ..
# 2  
Old 08-10-2010
Try this..

Code:
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

Code:
ls . | grep -v `cat input_file.txt`

# 3  
Old 08-10-2010
Code:
cat filename | xargs ls

will automatically use the ls error message to print "No such file or directory"
# 4  
Old 08-10-2010
Bug

Hey thanks 4 ur respomse


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

Pls suggest
# 5  
Old 08-10-2010
Code:
echo `cat filename | xargs ls`

# 6  
Old 08-10-2010
Quote:
Originally Posted by ultimatix
Code:
 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 )
Also try,


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

This User Gave Thanks to clx For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to find list of missing files based on the file format?

Hi All, In the file names we have dates. Based on the file format given by the user, if any file is not existed for a particular date with in a given interval we should consider that file is missing. I have the below files in the directory /bin/daily/voda_files. ... (9 Replies)
Discussion started by: nalu
9 Replies

2. Shell Programming and Scripting

Find missing .ibd files

Hi, I have mysql file that extension is .frm and .ibd file. I am trying the to get command line utility to get missing .ibd file. for example: Input : $ ls -al -rw-rw---- 1 mysql mysql 8684 Dec 22 12:22 a.frm -rw-rw---- 1 mysql mysql 114688 Feb 5 16:01 a.ibd -rw-rw---- 1... (3 Replies)
Discussion started by: k_manimuthu
3 Replies

3. Shell Programming and Scripting

Find list of files missing read & execute permission

Hi, I'm writing a post-upgrade script and I want to find which files don't have read and execute to everyone. I can run a find . ! -perm, but then I have to use a list of the possible permissions (777,775, 755 etc). Is there a more elegant solution? Thanks (2 Replies)
Discussion started by: Catullus
2 Replies

4. Shell Programming and Scripting

Find command to find a word from list of files

I need to find a word '% Retail by State' in the folder /usr/sas/reports/RetailSalesTaxallocation. When I tried like below, -bash-4.1$ cd /usr/sas/reports/RetailSalesTaxallocation -bash-4.1$ find ./ -name % Retail by State find: paths must precede expression: Retail Usage: find ... (10 Replies)
Discussion started by: Ram Kumar_BE
10 Replies

5. Shell Programming and Scripting

Compare 2 files and find missing fields awk

Hello experts! I have 2 files. file1 is a list file containing uniquely names. e.g.: name1 number number name2 number number name5 number number name10 number number ... file2 is a data file arbitrary containing the names of file1 in paragraphs separated by "10" e.g. name4 ... (3 Replies)
Discussion started by: phaethon
3 Replies

6. Shell Programming and Scripting

Create a list of missing files

Hello Guys I have a big list of files in one directory. And Some are missing . Example ls -l 2191off-r0.sps 2193off-r0.sps 2194off-r0.sps 2197off-r0.sps 2198off-r0.sps 2200off-r0.sps I would like to create a file with the list only missing files. Or if is possible to create in ... (4 Replies)
Discussion started by: jiam912
4 Replies

7. Shell Programming and Scripting

Help need to find out the missing files in the directory

Hi All, Below is my requirement. I want to display the missing files in the directory. Below is my example From SFTP we are copying 10 files every day. if any files missed on that day need to send a notification with missing files Test1.dat 20121107_00_file.csv 20121107_01_file.csv... (8 Replies)
Discussion started by: bbc17484
8 Replies

8. Shell Programming and Scripting

Compare 2 folders to find several missing files among huge amounts of files.

Hi, all: I've got two folders, say, "folder1" and "folder2". Under each, there are thousands of files. It's quite obvious that there are some files missing in each. I just would like to find them. I believe this can be done by "diff" command. However, if I change the above question a... (1 Reply)
Discussion started by: jiapei100
1 Replies

9. Shell Programming and Scripting

find list of files from a list and copy to a directory

I will be very grateful if someone can help me with bash shell script that does the following: I have a list of filenames: A01_155716 A05_155780 A07_155812 A09_155844 A11_155876 that are kept in different sub directories within my current directory. I want to find these files and copy... (3 Replies)
Discussion started by: manishabh
3 Replies

10. AIX

how to find missing files

Hi on friday one user from peoplesoft lost his file. mean he don't know he saved it or removed it. but, he need the file and it is most valuable. so i searched the file in the server, i got the some with same name on /peoplesoft/..../print directory. is these two are the same one or... (1 Reply)
Discussion started by: honeym210
1 Replies
Login or Register to Ask a Question