Copy a file which is generated every day

By | September 8, 2009

When you want to copy a file which is generated every day and has a date inserted inside its name, you can use the following bash file:

#!/bin/bash
dt=`date +%Y%m%d`
#dt=`date +%Y%m%d%H%M%S`
from_dir=”/home/adrian/1″
to_dir=”/home/adrian/2″
from_file=”$from_dir/myfile”_”$dt”.csv
to_file=”$to_dir/myfinalfile.csv”;
#echo “cp $from_file $to_file”
cp $from_file $to_file
#!/bin/bash
dt=`date +%Y%m%d`
#dt=`date +%Y%m%d%H%M%S`
from_dir=”/home/adrian/1″
to_dir=”/home/adrian/2″
from_file=”$from_dir/myfile”_”$dt”.csv
to_file=”$to_dir/myfinalfile.csv”;
#echo “cp $from_file $to_file”
cp $from_file $to_file

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.