How can I get human-readable ls output under AIX? There is no -h parameter
6 Answers
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 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 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.
Colorized ls for AIX(with Perl). Works for most flavors of Unix too, like Sun etc.
This is ugly, but it works great! I got it from www.shell-fu.org, so not taking credit for someone elses work. I created an alias in my .bashrc called dux to implement this trick. Copy this code:
alias dux='du -sk ./* | sort -n | awk '\''BEGIN{ pref[1]="K"; pref[2]="M"; pref[3]="G";} { total = total + $1; x = $1; y = 1; while( x > 1024 ) { x = (x + 1023)/1024; y++; } printf("%g%s\t%s\n",int(x*10)/10,pref[y],$2); } END { y = 1; while( total > 1024 ) { total = (total + 1023)/1024; y++; } printf("Total: %g%s\n",int(total*10)/10,pref[y]); }'\''' Yes, its very long, but it produces a human readable, sorted from smallest to largest output, so when you are looking for what's taking up all the space, the answers are right above your cursor when it finishes.
Example:
Give it a try, I love it!

lsoutput that isn't human-readable?ls -lhconverts sizes into kilobytes, megabytes and gigabytes.