Make file with name equal to current date / time in Unix

Posted on 2007-08-03
Last Modified: 2013-11-05
What is the easiest way create a file with a name equal to the current date time? I would like to run the same script and have the files saved in the same location with names that change based on date/time.

Ideally, if the time was 9:43 on August 3, 2007 the output would be filename_2007.08.03_21:43

I thought this would be trivial but I have scoured the web and have not found any answers. I am using terminal in OS X. Please Help!!!
Question by:MattLor
    LVL 84

    Accepted Solution

    touch filename_`date +%Y.%m.%d_%H:%M`

    Author Comment

    THANKS for the quick response! You saved me hours! I had seen this solution somewhere else but was using single quotation marks instead of hash marks.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    A short article about a problem I had getting the GPS LocationListener working.
    This is about my first experience with programming Arduino.
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
    Video by: Phil
    This video goes over how to configure and start a jail in FreeBSD.  This video is meant to supplement the article included with this course.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now