[SWLUG] timestamp in bash script

Dafydd Walters dafydd at walters.net
Thu Dec 19 05:46:00 UTC 2002


On Wed, 2002-12-18 at 19:29, bascule wrote:
> is there a way to obtain the time and date of a file without having to parse 
> the ls command output?

stat should work, so for example in a bash script, you could set a
variable MYVAR to the modification date/time of a file whose name is
stored in the variable FNAME with the following line:

MYVAR=`stat -c "%y" ${FNAME}`






More information about the Swlug mailing list