Monday, October 27, 2008

The date command in unix

In unix, the date command is to show the current date and time.

If you are the root, you can use the date command to set the system date (i.e. the current date as reported by the unix machine). Since the majority of the users are not root, for most of the time this command is used for display.

Without any parameter, just type the date command will display the current date and/or time in the default format.

But, you can set the display format as you like.

Usually, I will create file with a filename having the current date-time. Then I will use this date command. Here it is:

touch my_file.d`date +"%Y%m%d%H%M%S"`

Assuming now is 2008-12-31 23:58:59, this will create a file my_file.d20081231235859


No comments:

Duplicate Open Current Folder in a New Window

Sometimes after I opened a folder in Win7, I would like to duplicate open the same folder again in another explorer window. Then, I can ope...