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

Get filename date and time attributes

Status
Not open for further replies.

BobAngilella

IS-IT--Management
Joined
Mar 11, 2003
Messages
1
Location
US
Under the bourne shell, how can I get a file's date and time assigned to shell script variables?
 
One way to do this is to pipe the "l" command through "awk" and save the output to the variable, like this:

variable=`l -T filename | awk '{printf("%s",substr($0,42,20))}'`

This formats the file date and time exactly like the "l" command with the "-T" parameter ("MMM DD HH:MM:SS YYYY"). If you need a different format you will need to modify the awk command to change this to the desired format (see "man awk" for help in awk scripting).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top