I want to make a script in Unix in which I have to move a file daily to a specific path. In order to avoid overlapping of the file, I want the file name along with the date.

e.g. mv filename /home/bin.
How can I add the date to the file name?

migrated from stackoverflow.com Mar 25 '12 at 18:12

This question came from our site for professional and enthusiast programmers.

mv "filename.ext" "/home/bin/filename-$(date +%Y%m%d).ext"
mv filename.ext{,.$(date +%Y%m%d)}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy