Apparently, there’s no native shell command to show the seconds portion of a unix file timestamp. The nearest to this functionality is stat. However, it’s not always available in unix systems. I’m using HP-UX and it’s not installed on our server.

Instead, I needed to use a one-line perl program shown below.

perl -e .foreach(@ARGV){$t =localtime ( ( ( stat ( $_ ) ) [9] ) ); printf(.%-20s %sn.,$_,$t);}. filename.txt

My perl knowledge is limited to its name. I have nothing beyond that. That’s my way of saying ‘I don’t know what it is.’ But it works!


Comments are closed.

Post Navigation