7

How can I get human-readable ls output under AIX? There is no -h parameter

  • 2
    What is there in the ls output that isn't human-readable? – n0pe Aug 30 '11 at 15:16
  • 2
    To other readers: ls -lh converts sizes into kilobytes, megabytes and gigabytes. – Steve-o Aug 31 '11 at 6:27
5

Might I suggest ls -ls?

That will provide the files sizes in KB instead of the default blocks.

Ex:

36 -rw-r--r--    1 oracle   dba           33875 Feb  2 2011  step2.log
32 -rw-r--r--    1 oracle   dba           30308 Feb  2 2011  step2.sql
7

You can use du. It does not have -h option, but it has -k -m and -g:

$ du -m /tmp/*

4.84    /tmp/diagSEgenSnap
33.12   /tmp/fwupdate

$ du -k /tmp/*

4952    /tmp/diagSEgenSnap
33920   /tmp/fwupdate
1

I can't imagine this:

find -maxdepth 1 -ls

being the best solution, but I don't have an AIX. And do you have gnu-find on AIX? If not - I don't know how the output of other finds looks like.

This is gnu-find:

     4    7 drwxr-xr-x 115 stefan   stefan       6880 Aug 30 12:43 .
247530    0 lrwxrwxrwx   1 stefan   stefan         10 Mär 20  2010 ./u1 -> Ubuntu\ One
 45706    0 drwxr-xr-x   3 stefan   stefan         80 Mai 29  2010 ./.m2
  9352    0 drwxr-xr-x   3 stefan   stefan        168 Apr 20 16:26 ./.mc
 83653    0 drwxr-xr-x   2 stefan   stefan        120 Feb 19  2010 ./.qt
 82474    0 drwx------   2 stefan   stefan        128 Apr 27  2009 ./PDF
 18316   24 -rw-r--r--   1 stefan   stefan      21925 Aug 30 15:42 ./.scala_history
257889    4 -rw-------   1 stefan   stefan        230 Mär 18 06:30 ./.gtk-bookmarks
267759    4 -rw-r--r--   1 stefan   stefan        395 Jan  2  2011 ./brownies.txt

If you don't have any other option, an alias might be useful.

1

Try this

ls -l | awk '{$5=sprintf("%.9f GB", $5/1024^3)} 1'
1

Colorized ls for AIX(with Perl). Works for most flavors of Unix too, like Sun etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.