I have written the following script to copy files from a directory to another directory and add time stamp to the copied file and remove the original file. I want to know if it is good for bash scripting.
#!/bin/bash
for FILES in ./current/*
do
cp -ur $FILES /previous/${FILE}.`date +%m%d%Y`
rm ./current/$FILES
done
I woud recommend using move instead of copy+remove, its faster. Modified version below:
#!/bin/bash
cd ./current
for FILES in *
do
mv $FILES /previous/${FILES}.`date +%m%d%Y`
done
That looks good.
Thanks
My VPN is not working. So, i have not been able to test.
Please log in to reply to this post
You can also log in using your Facebook
What people are reading
You might like these other discussions...
· Posts 9
· Viewed 12671
· Likes 1
· Posts 7
· Viewed 4109
· Likes 1
· Posts 21
· Viewed 10264
· Likes 1
· Posts 5
· Viewed 7873
· Likes 1