Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I create a timestamp in a shell script?

Status
Not open for further replies.

cpjust

Programmer
Sep 23, 2003
2,132
0
0
US
Hi,
I know in C you use the time() function to get the number of seconds since the epoch, but I can't find a command that does the same thing. There must be a standard UNIX command that does it somewhere right?
 
Nevermind, I found it:
Code:
date +%s
 
If you are using ksh93 you can also use printf "%(%s)T" to return the number of seconds since the Epoch. This avoids a call to an external utility such as date.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top