A handy Unix command is
test which can check for the existence of a file for example and rename it. Here’s an example:
test -f test.txt && mv test.txt test.txt.`date +%Y%m%d-%H%M%S`
This first tests if the file
If it does, it renames the file to
test.txt.YYYMMDD-HHMMSS (appropriate date/time stamp).
Great for scripts that are working with say a log file and need to rename it before starting a new log.