I have this to get the timestamp of a directory:
stat -c %Y directory_name
What can I pipe this to, to get the date formatted like this?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
stat -c %Y is specific to the GNU implementation of
stat. If have GNU
stat on your Solaris machine, it's likely you'll also have GNU
find where you can just do:
gfind dir -prune -printf '%TY%Tm%Td\n'
You'll probably also have GNU
date, with which you can do:
gdate -r dir +%Y%m%d
(though beware that if
dir is a symlink, it will give you the modification time of its target, not the symlink itself).
Solaris also comes with
zsh which has its own
stat builtin (and has had long before a
stat utility was added to GNU coreutils) where you can do:
zmodload zsh/stat stat -LF %Y%m%d +mtime dir