Riaan's SysAdmin Blog

My tips, howtos, gotchas, snippets and stuff. Use at your own risk!

AIX

AIX with no human readable ls

I recently had to touch a pretty old AIX OS and it frustrated me not to have human readable output for ls. This function helped a little. An alias did not want to work because of all the quoting going on. Of course as you can notice I changed my shell prior to bash.

> oslevel -g
Fileset                                 Actual Level        Maintenance Level
-----------------------------------------------------------------------------
bos.rte                                 5.3.7.0             5.3.0.0

> more .profile
...
function ls-h() {
  /usr/bin/ls -l "$@" | awk "{\$5=sprintf(\"%.2f GB\", \$5/1024^3)} 1";
}
...
PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin:.
export PATH

# alias has to many """ chars to work trying function ls-h
#alias lsh "ls -l \$@ | awk '{$5=sprintf("%.2f GB", $5/1024^3)} 1'"

> ls-h /u28/oracle/uat2data/
total 830472432   0.00 GB
-rw-r----- 1 ora dba 31.00 GB Jul 14 00:46 a_ora_file.dbf

admin

Bio Info for Riaan