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.
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
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