Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

df -g output in columns in AIX

Status
Not open for further replies.

remurden

Programmer
May 22, 2013
3
US
I grabbed this from a previous thread that is now closed. I used this to get the ouput for the df command:

df|awk -F" " '{ if (length($1) > 15 ){printf("%s\t%s\t%s\t%s\t%s\n",$1,$2,$3,$4,$5)} else {printf("%s\t\t%s\t%s\t%s\t%s\n",$1,$2,$3,$4,$5)} } '

problem is when i use df -g |awk -F" " '{ if (length($1) > 15 ){printf("%s\t%s\t%s\t%s\t%s\n",$1,$2,$3,$4,$5)} else {printf("%s\t\t%s\t%s\t%s\t%s\n",$1,$2,$3,$4,$5)} } '
I get ouput like this. Is there a way to exclude the word "blocks" when using the command?

Filesystem GB blocks Used Free %Used Mounted on
/dev/hd4 2.00 0.51 1.49 26% /
/dev/hd2 8.00 3.11 4.89 39% /usr
/dev/hd9var 4.00 0.70 3.30 18% /var
/dev/hd3 4.00 0.06 3.94 2% /tmp
/dev/hd1 8.00 0.36 7.64 5% /home
/dev/hd11admin 0.50 0.00 0.50 1% /admin
 
df -g |awk -F" " '{sub(/blocks/,"");if (length($1) > 15 ){printf("%s\t%s\t%s\t%s\t%s\n",$1,$2,$3,$4,$5)} else {printf("%s\t\t%s\t%s\t%s\t%s\n",$1,$2,$3,$4,$5)} } '

Regards,
Chuck
 
thanks, works perfect! Learned something new with awk.
Thanks,
Richard
 
I am having trouble creating an alias for this in my .profile. I tried this:
alias dfg='df -g |awk -F" " '{sub(/blocks/,"");if (length($1) > 15 ){printf("%s\t%s\t%s\t%s\t%s\n",$1,$2,$3,$4,$5)} else {printf("%s\t\t%s\t%s\t%s\t%s\n",$1,$2,$3,$4,$5)} } ''

the result i get when i logback in is: ksh: 0403-057 Syntax error: `(' is not expected.

I have tried it a few more ways but this is the closet i got, at least, i think. Any suggestions would be graeat.
Thanks,
Richard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top