Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


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

Posted on 2007-08-03
Medium Priority
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 85

Accepted Solution

ozo earned 2000 total points
ID: 19630072
touch filename_`date +%Y.%m.%d_%H:%M`

Author Comment

ID: 19630234
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.

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Make the most of your online learning experience.
No other job is as rewarding and demanding as building an iPhone app is. It is not really in the hands of the developer for the success of an iPhone app. Many factors operate jointly for every iOS application's success in the market.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses

578 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