Results 1 to 2 of 2
Thread: Appending date to filenames
Enjoy an ad free experience by logging in. Not a member yet? Register.
- Join Date
- Aug 2011
Appending date to filenames
I have a requirement like this, I have to save log files appended with current date and time.I did "logger.sh > log`date +%T%D`" it is saying no such file or directory.I omitted %D then it works.But I need both.One more thing if I want to put a separator between time and date what to do.For example
I can see the issue here. The date %D returns / formatted date. e.g. MM/DD/YY
This will obviously try saving to a file named YY in the folder called "%TMM/DD"
to get around this, you will likely need to use a different date format.
As for formatting it, you can literally put whatever formatting you want in the +string.
e.g. to get what you want, but with - instead of / in the date:
logger.sh > log-`date +%T$%m-%d-%y`"I am not an alcoholic, alcoholics go to meetings"
Registered Linux user = #372327