since the OSX and Ubuntu versions of stat
have some differences in that OSX stat
defaults to terse output and Linux stat
defaults to verbose some hoops would need to be jumped through. One possibility would be to simply use an alias on OSX would make stat perform the same on both.
If you don't mind setting an alias to force verbose output of stat
on OSX with alias stat="stat -x"
then you don't need perl.
stat .bashrc| grep Modify
is all you need under Ubuntu. if you set the alias as above it works under OSX as well
Example from Ubuntu 14.04.5 Virtually identical results can be obtained from Ubuntu 16.04
stat .bashrc| grep Modify
Modify: 2014-03-30 23:14:47.658210121 -0500
If all you want is the timestamp you can strip the Modify:
and retain the rest with
stat .bashrc| grep Modify | cut -c 9-
Sources:
https://ss64.com/osx/stat.html
Output of stat on OSX