1

I’m looking for a command on AIX 7.1 that can give me filenames, size, and complete date/time (in a uniform format).

  • ls -l and similar commands have the drawback that they give date (month and day) and time (hour and minute), if the file is not older than 6 months, and date and year otherwise.  (I want year, month, day, hour, minutes and seconds for all files.)
  • The AIX version of ls does not support --full-time, reporting

    ls: Not a recognized flag: -
    ls: Not a recognized flag: -
    Usage: ls [-1ACFHLNRSabcdefgiklmnopqrstuxEUX] [File...]
    

What command that exists on AIX will give me the full date/time, in a consistent format, and the file size?

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255

2 Answers2

1

Indeed, istat appears to solve your problem; from the man page:

$ istat /usr/bin/ksh

Inode 10360 on device 10/6    File
Protection: r-xr-xr-x
Owner: 2(bin)     Group: 2(bin)
Link count: 2     Length 372298 bytes

Last updated:  Wed May 13 14:08:13 1992
Last modified: Wed May 13 13:57:00 1992
Last accessed: Sun Jan 31 15:49:23 1993

... gives the file size and full timestamps.

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
1

Both istat and perl may be of help:

#!/usr/bin/env bash

echo
rm -f f1
touch f1

echo
echo " With perl:"
perl -e '@d=localtime ((stat(shift))[9]); printf "%02d-%02d-%04d %02d:%02d:%02d\n", $d[3],$d[4]+1,$d[5]+1900,$d[2],$d[1],$d[0]' f1

echo
echo " With istat:"
istat f1

producing:

$ ./s1


 With perl:
14-10-2017 14:26:01

 With istat:
Inode 1371634 on device 45/3    File
Protection: rw-r--r--   
Owner: 1296(drl)                Group: 100(usr)
Link count:   1         Length 0 bytes

Last updated:   Sat Oct 14 14:26:01 DFT 2017
Last modified:  Sat Oct 14 14:26:01 DFT 2017
Last accessed:  Sat Oct 14 14:26:01 DFT 2017

On a system like:

aix 7.1.0.0
istat - ( /usr/bin/istat, Aug 08 2010 )
perl 5.10.1

Best wishes ... cheers, drl

( With advice from http://www.unix.com/shell-programming-and-scripting/41325-command-get-file-timestamp-including-seconds-aix-5-3-a.html )

drl
  • 838