Check daily files arrival in a directory

Hi All,

I wanted to write a script to check if set of files exist in a directory or not for a particular day. each file has a date stamp. Now i want to implement this -
-i can check files of a particular date in a particular folder
-generate log and send it to through email.

Big THANKS !! in advance.

What have you tried so far?

Hi pilnet101,

Thanks for your reply.
I am just beginner in unix and wrote this code with the help of online tutorials so far for 2 files -

#!/bin/bash

echo "Enter date of file"
read date;
for x in {1}  ; 
do
    if [[ -f "new1_$date.txt" ]]; then
        echo "new1_$date.txt is a present"
    else 
        echo "BOOOOO...new1_$date.txt is absent"
fi
	if [[ -f "new2_$date.txt" ]]; then
        echo "new2_$date.txt is a present"
    else 
        echo "new2_$date.txt is absent"
    fi

if [[ -f "new3_$date.txt" ]]; then
        echo "new3_$date.txt is a present"
    else 
        echo "new3_$date.txt is absent"
    fi


done

but this isn't working for all files.

i have files like this -

howdy_20140925_XXXX.txt
hello_20140925_xxxx.txt
Fine_20140925.2599

these files come daily and i need to write script to check whether they come or not.

Thanks.

Please use [ code ] tags around your code, makes it much easier to read AND help fixing it....
Also, what is the output you get?

In recent bash , you could use extended pattern matching (cf. man bash) to get your result:

[ 3 -eq $(ls @(Fine|hello|howdy)*$date* | wc -w) ] && echo good || echo bad

What irritates me is this, in the script you check for "new[1-3]$date.txt", but you have files named "hello,hody,Fine" which is about same weird.

read -p "Please enter the date: " date
list=($(ls *$date*))
[[ -z "$list" ]] && echo "No files with this date ($date) available" && exit 1
for F in "${list[@]}";do
    echo "Found file: $F"
done