Skip to content

Instantly share code, notes, and snippets.

@iambibhas
Created November 18, 2013 18:40
Show Gist options
  • Save iambibhas/7533012 to your computer and use it in GitHub Desktop.
Save iambibhas/7533012 to your computer and use it in GitHub Desktop.
Having datetime in file name with shell script

Date time for file name -

$ date +"%b-%d-%y"
Nov-19-13
$ touch `date +"%b-%d-%y"`.txt # works

Full list -

%a : Abbreviated weekday name (Sun..Sat)
%b : Abbreviated month name (Jan..Dec)
%B : Full month name, variable length (January..December)
%d : Day of month (01..31)
%e : Day of month, blank padded ( 1..31)
%m : Month (01..12)
%Y : Year
%d : Day of month (e.g, 01)
%H : 24 hour format (00..23)
%I : 12 hour format (01..12)
%j : day of year (001..366)
%D : date; same as %m/%d/%y
%F : full date; same as %Y-%m-%d (a good format for sorting filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment