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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I grab the seconds value in a file timestamp as a string. 1

Status
Not open for further replies.

ddeleo

Programmer
Joined
Jul 26, 2004
Messages
2
Location
US
Is there a way to access/capture the seconds on the file timestamp. I understand that this timestamp is hour, minutes, and seconds, yet the ls -ls command only shows hour and minutes. I am using the Korn shell. Thanks!
 
Here an example (using perl from ksh):
file="/path/to/file2test"
eval $(perl -e '
($ss,$mn,$hh,$dd,$mm,$yy,$wd,$yd,$dst)=localtime((stat("'$file'"))[9]);
printf("DATE=%04d%02d%02d\n",$yy+1900,$mm+1,$dd);
printf("TIME=%02d%02d%02d\n",$hh,$mn,$ss)')
echo "$file:"$DATE,$TIME

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top