Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Appending date to filenames

    Hi All,
    I have a requirement like this, I have to save log files appended with current date and time.I did " > 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



  2. #2
    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: > log-`date +%T$%m-%d-%y`
    "I am not an alcoholic, alcoholics go to meetings"
    Registered Linux user = #372327

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts