I'm using a script that I need to get a file's "last modified date" in a format like 01:51:14 PM. We are running on AIX 6.1.0.0. I can't seem to find the right command parameters. Help!
the trick to get the last modified time in epoch:
cpio -o 2>/dev/null <<EOF | od -d | awk '
NR == 2 {print $2 * 65536 - $3;exit}'
myFile
EOF
Given epoch time, you can convert it to human-readable format.
Do you have truss
on AiX?
If so, you may truss this:
truss -f -v 'lstat,lstat64' ls -d myFile 2>&1 | grep 't ='
I guess in perl you can do it in one swoop.
NOTE: use 'nawk' on Solaris
---------- Post updated at 03:29 PM ---------- Previous update was at 03:28 PM ----------
Thanks for the reply. WHERE do I reference the file I'm waring the date on? HOW can I assign the output of this code to a variable to be used in a script?
modified the original reply - now it should be obvious.
What about
istat "filename"
?