Help need to find out the missing files in the directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help need to find out the missing files in the directory
# 1  
Old 11-09-2012
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

Code:
Test1.dat

20121107_00_file.csv
20121107_01_file.csv
20121107_02_file.csv
20121107_03_file.csv
20121107_06_file.csv
20121107_08_file.csv
20121107_09_file.csv

Output should be like below

Code:
20121107_04_file.csv
20121107_05_file.csv
20121107_07_file.csv

Note: Those file list I am maintaining in one .dat file for checking the count and processed date.

Thanks,
Chandu.
# 2  
Old 11-09-2012
Is that the exact filename structure.
Have you thought about something like
ls > file1
then use the diff command
see ...
https://www.unix.com/unix-dummies-que...f-command.html
# 3  
Old 11-09-2012
Hi Joeyg,

I am not taking any differences between the files. That is the exact file name structure and files will come every one hour. our process will pick all those files to load int to stage.

Need to drop notification if any hour file missed in between. Is there any way to write it using awk programming

Thanks,
chandu.
# 4  
Old 11-09-2012
Code:
TS=$( date +"%Y%m%d" )

for SEQ in 00 01 02 03 04 05 06 07 08 09
do
        if [ -f "${TS}_${SEQ}_file.csv" ]
        then
                :
        else
                echo "${TS}_${SEQ}_file.csv is missing"
        fi
done

This User Gave Thanks to Yoda For This Post:
# 5  
Old 11-09-2012
no 08?
# 6  
Old 11-09-2012
Not my lucky number Smilie Thanks for pointing that out Smilie
# 7  
Old 11-09-2012
for more bash:
Code:
TS=$( date +"%Y%m%d" )

for SEQ in {0..9}
do
        file=$(printf "%s_%02d_file.csv" $TS $SEQ)
        [[ -f "$file" ]] || echo "$file is missing"
done

This User Gave Thanks to rdrtx1 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

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

5. UNIX for Dummies Questions & Answers

Directory missing .how to find the cause .

Hi, i am using rhel6.4, i lost my directory under /home .is there any way to find the reason how that directory deleted and how to recover deleted folder. (2 Replies)
Discussion started by: sayhirams
2 Replies

6. UNIX for Advanced & Expert Users

Find all files in the current directory excluding hidden files and directories

Find all files in the current directory only excluding hidden directories and files. For the below command, though it's not deleting hidden files.. it is traversing through the hidden directories and listing normal which should be avoided. `find . \( ! -name ".*" -prune \) -mtime +${n_days}... (7 Replies)
Discussion started by: ksailesh1
7 Replies

7. Shell Programming and Scripting

Find missing files from a list

counter=0; while read line; do ] && 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... (5 Replies)
Discussion started by: ultimatix
5 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. UNIX for Dummies Questions & Answers

Find files and display only directory list containing those files

I have a directory (and many sub dirs beneath) on AIX system, containing thousands of file. I'm looking to get a list of all directory containing "*.pdf" file. I know basic syntax of find command, but it gives me list of all pdf files, which numbers in thousands. All I need to know is, which... (4 Replies)
Discussion started by: r7p
4 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