Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

finding file patterns

Status
Not open for further replies.

samirm

Technical User
May 12, 2003
80
US
Hi ,

In my Unix box, in a particular location say in /home/samir/office on regular basis 6 files get copied from various remote servers via FTP on a particular time.

Now I would like to make a shell script which will work in background to keep track of that files and will mail me with the confirmation.

The files are 6 nos. on daily basis.

file name is like as folows :-

abc40218.csv
def40218.csv
ghi40218.csv
jkl40218.csv

abc_def_pqr20040218.csv
abc_123_def20040218.csv

for 1st group of files 4 = year , 02 = month and 18 = day

and for 2nd group of files 2004 = year, 02 = month and 18 = day

Thanking you ....

Samir

 
If you're running this every day, then do you need to worry about the dates in the filenames?

You could just wait until there are 6 files
Code:
while true; do
  a=`ls -1 | wc -l`
  if [ "$a" -eq "6" ]; then
    echo yes  # replace with suitable mail command
    break
  fi
  sleep 10
done

--
 
Hi Salem ..thanks for the reply ..
but if this thing happen for once / twice a week ..then what things to be followed ?

for any holiday / special close day ...

I need a general solution irrespective of the daily files ..as u said ..with that respective time stamp.

thanks ..

samir
 
samirm, what have you so far ?
To list today's files, you can try something like this:
typeset -i ymd=$(date "+%y%m%d")
ls /home/samir/office/*$ymd.csv

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Thanks PHV .

I will let you know the outcome of your script idea ..after apply !!

samir
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top