0

How to change the filename from file.txt to renaming it to be file_may_20_2020.txt using mv command?

I have used

mv file file_(`date`).txt

I still don't know how to put a command inside another command

Talha Tayyab
  • 8,111
  • 25
  • 27
  • 44
joan
  • 39
  • 3
  • Does [this](https://stackoverflow.com/questions/23733669/rename-file-command-in-unix-with-timestamp) answer your question? Use the search, Luke. ;) – tink Jun 12 '22 at 20:03

2 Answers2

1

Use either

mv file file_"`date +"%B_%d_%y"`".txt

or

mv file file_"$(date +"%B_%d_%y")".txt
Tolis Gerodimos
  • 3,782
  • 2
  • 7
  • 14
0

mv file file_"$(date +"%B_%d_%y")".txt

What you put inside the $ is like a template string and its value is placed in the string