I use stat -f %m .bashrc
to get modification time of my .bashrc on osx. But when I run the same command on ubuntu, it spits error:
stat: cannot read file system information for %m': No such file or directory
is there a compatible way to achieve this?
Best Answer
Ubuntu uses the GNU coreutils
stat
, whereas OSX uses the BSD variant. So on Ubuntu the command is a bit different:From
man stat
:and:
If you want a portable way to run these regardless of OS, then there are several ways of doing it. I think I would set a variable one time to the appropriate parameters:
And then use this value in the
stat
command wherever needed: