Script to check for the newest file mutiple times a day and SCP it to another server.

Hi, I need a sample of a script that will check a specific directory multiple times throughout the day, and scp the newest file to another server.

Example: current file is misc_file.txt_02272011 (the last part is the date), once that has been secure copied, another one may come in later the same day named misc_file.txt_002272011A, which needs to be copied as well. The next day a new file will come in named misc_file.txt_02282011.

I'll probably rename the previous file to .DONE, or someting like that.

in ksh you can use the condition

if [[ ... -ot ... ]];then ...; fi
if [[ ... -nt ... ]];then ...; fi

(older than, newer than)

Or you might want to use a better naming convention : YYYYMMDD instead of your MMDDYYYY .

ls -t | head -1

?