Languages and Scripting
Showing results for 
Search instead for 
Do you mean 

want only two field in bdf output.

Occasional Advisor

want only two field in bdf output.

Hi,
I am trining to make a script which will show me only mountpoint and %used. I tried using bdf |awk '{print $5 , $6}' but as bdf output for one mountpoint is coming in two line so i am not able to do.
Filesystem kbytes used avail %used Mounted on
/dev/vg00/lvol3 5144576 272768 4833832 5% /
/dev/vg00/lvol1 2097152 334152 1749296 16% /stand
/dev/vg00/lvol8 12288000 5484256 6752136 45% /var
/dev/vg00/lvol7 8192000 3444072 4710880 42% /usr
/dev/vg00/lvol6 8192000 2062232 6082112 25% /tmp
/dev/vg00/lvol5 10256384 5671680 4549056 55% /opt
/dev/vg00/lvol4 10256384 1534216 8654104 15% /home
/dev/vg00/lvol9 15728640 8342293 6924807 55% /app
/dev/vg00/secure 5144576 18754 4805464 0% /.secure
/dev/vgosmapp/lvol1
35323904 10801593 22989765 32% /osmapp
3 REPLIES
Esteemed Contributor Esteemed Contributor

Re: want only two field in bdf output.

Whit this, you will have only one line for each FS:

# bdf | awk '{if (NF==1) {line=$0;getline;sub(" *"," ");print line$0} else {print}}'

Regards,
"When you look into an abyss, the abyss also looks into you"
Occasional Advisor

Re: want only two field in bdf output.

Hey,
Thanks aa ton...the output is coming in one line so i can use awk now.
Highlighted
Acclaimed Contributor Acclaimed Contributor

Re: want only two field in bdf output.

Or simply:
bdf | awk 'NF != 1 {print $(NF-1), $NF}'