Sunday, April 28, 2024
13
rated 0 times [  13] [ 0]  / answers: 1 / hits: 31940  / 2 Years ago, tue, august 2, 2022, 3:43:12

Using the command-line, I want to create a log file with today's date in the name (for example, today is 05/17/2011, so the filename would have to be log051711).



I know how to create the file (touch filename), but I don't know how to get today's date. I have looked at the manual for date, but it seems that I can't really format its output?



Any help would be appreciated.


More From » command-line

 Answers
0

You can format the output using the '+FORMAT' parameter, e.g.



touch "log$(date +'%m%d%y')"


See the manpage for what sequences you can use in FORMAT.


[#42876] Tuesday, August 2, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
byishted

Total Points: 469
Total Questions: 113
Total Answers: 113

Location: Tajikistan
Member since Sun, Aug 29, 2021
3 Years ago
;