9

How to do below in one bash command ? I mean rename file to current date

$ echo `date +"%m-%d-%y"`
01-14-16
$ mv backup1.tar 01-14-16

1 Answer 1

16
mv backup1.tar "$(date +"%m-%d-%y")"

$(...) is an alternative syntax to ``. This will first execute $(date +"%m-%d-%y"), so that the command line really becomes mv backup1.tar 01-14-16.

Please note that it might be good to do some checking here, e.g. if the file already exists.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.