Hi,
I am a new for shell script. i need to write script using the following commands
cd /usres/test
# create directory
mkdir temp+DATE( i need to append date )
#moving files from one directory to this directory(we need to check total files in source and taget)
cd /users/sample
mv *gz /users/test/temp+DATE
please give me idea how to write this script.
Thanks
You've got most of it already. For appending the date, just do this:
In ksh/bash:
mkdir temp$(date +%Y%m%d)
Of course, you can change the format of the date by modifying the format specifications in the date command.
date=$( date +%Y-%m-%d ) ## Use ISO standard date format
for file in *.gz
do
mv "$file" "/users/test/temp/${file%.gz}-$date.gz"
done