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

Read Date/Time Information from a file 1

Status
Not open for further replies.

jestrada101

Technical User
Mar 28, 2003
332
How can I read the date/time information and pass into a shell variable?

Many thanks
je
 
#!/bin/sh

todaysDate=`date`
echo "$date"



date has several options to choose from. read the man page.
type man date
 
Sorry.. I mean reading a date stamp from a file.. like when it was modified.. created, etc?

Thanks
je
 
oops, your subject header specified 'from a file'...

#!/bin/sh

ls -l | while read line
do
fileName=`echo $line | awk '{print $NF}'`
fileDate=`echo $line | awk '{print $6}'`
fileTime=`echo $line | awk '{print $7}'`

echo ""
echo "/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/"
echo "File Name: $fileName"
echo "File Date: $fileDate"
echo "File Time: $fileTime"
done

That should get you started.

HTH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top