« Awesome Bookmarks Sync with Google Browser Sync | Main | Unix Bash shell: matching files with one or more digits, but NOT other characters »

January 31, 2008

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a00d83420e7e053ef00e5501c1f938834

Listed below are links to weblogs that reference Unix Bash shell: formatting the current date into a timestamp:

Comments

Stephen

Yes, but use capital Y to get a 4 digit year.

mystring=`date "+%Y%m%d-%H%M%S"`

Y2K was only a few years ago. My files with automatic filenames from the 80's still sort in 'ls' properly with new files.

date "+%Y_%m_%d-%H:%M:%S"
is more human readable, and still does proper date/time sorting with 'ls'.

I have over a million files in my home directory (tree) on my home system. Some date to the 1970s. So, yes, they predate my use of Linux. My point is that you've no idea how long files will last. And you can even want old files retroactively (crossing the century boundary).

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been saved. Comments are moderated and will not appear until approved by the author. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment

Comments are moderated, and will not appear until the author has approved them.