Very often you have to work with date and time information in shell scripts.
date command takes various format options
1)MM/DD/YYYY
[username@hostname ]$ tname=$(date +%m/%d/%Y)
[username@hostname ]$ date +%m/%d/%Y
10/18/2011
[username@hostname]$ echo $tname
2)YYYYMMDDHH24MISS
[username@hostname ]$ tname=$(date +%Y%m%d%H%M%S)
[username@hostname ]$ echo $tname
20111018095553
No comments:
Post a Comment