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
jhapaliketo · Feb 8, 2011 11:58 PM · 11,225 views
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #163c4d} 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
M$Hacks · Feb 9, 2011 11:11 AM
That looks good. Thanks My VPN is not working. So, i have not been able to test.
jhapaliketo · Feb 9, 2011 12:57 PM
This conversation is preserved exactly as it was on the original Sajha.com and can't accept new replies.
Start a New Discussion