Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 12 Oct 2001 21:35:34 -0500
From:      Mike Meyer <mwm@mired.org>
To:        Randy Bush <randy@psg.com>
Cc:        questions@freebsd.org
Subject:   Re: date of a file
Message-ID:  <15303.43126.44123.116068@guru.mired.org>
In-Reply-To: <73720831@toto.iv>

next in thread | previous in thread | raw e-mail | index | archive | help
Randy Bush <randy@psg.com> types:
> i want to get the mtime of a file from a shell, so i can format it purty
> and do something with it.
> 
> in gnu-sh-utils, i can, for example,
> 
>    date -r filename +%y%m%d-%H%M%S
> 
> but, in freebsd, "date -r" says give me the current date in seconds of the
> epoch.
> 
> what should i be doing?

date +%y%m%d-%H%M%S -jf "%b %d %H:%M:%S" `ls -lT filename | awk ' { print $6, $7, $8, $9 } '` 

There are problably other ways to do it as well.

	<mike
--
Mike Meyer <mwm@mired.org>			http://www.mired.org/home/mwm/
Q: How do you make the gods laugh?		A: Tell them your plans.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?15303.43126.44123.116068>