awk print

Hi Team,

Can you please help me in this issue.

Am writing a shell script for checking diskspace in LINUX server. It's old server.

For example see my filesystem below:

$df -b
/rer                   (apdfp01.xxx.com:/var/adm/rash/MT) :   483331 Kbytes free
/dev/deviceFS1         (D1FS                 )    :        0 Kbytes free
/aeps/opt/best1        (/dev/bgsroot/lvbt1   )    :   1615 Kbytes free
/aeps/opt/bmc          (/dev/bgsroot/lvbc1     )  :   3186 Kbytes free
/aeps/opt/mqm          (/dev/bgstsmapp/lvmc1   )  :   11124 Kbytes free
/aeps/opt/openv        (/dev/bgsroot/lvop1   )    :  1072359 Kbytes free
/aeps/opt/seos         (/dev/bgsroot/lves1    ) :   315496 Kbytes free
/aeps/opt/var/mqm      (/dev/bgstsmapp/lvqm)    :  2059174 Kbytes free
/aeps/support          (/dev/bgsroot/lvsupt )     :   230387 Kbytes free
/aeps                  (/dev/bgsroot/lvvbpps) :  1686712 Kbytes free
/home                  (/dev/bgsroot/lvhme    ) :    89614 Kbytes free

if i try to give this command in shell scripting. Am getting this issue. Please help me to resolve this issue.

$df -b | grep -v Use | grep -v none | awk '{ print $5 }'
Kbytes 
0
1615 
3186 
11124
1072359  
315496 
Kbytes
230387
1686712
89614

Please help me to resolve this issue.

Thanks in Advance,
Indu

Replace existing awk program with:

awk '{ gsub(/.*: |Kbytes.*/,x); print } '

OR

awk '{ gsub(/.*: |Kbytes.*/,x) } 1'

OR

awk '{ gsub(/.*: |[a-zA-Z]*/,x) } 1' 
1 Like

I like this ( if gawk is avaliable ):

gawk 'match($0,/:[[:space:]]+([[:digit:]]+)[[:space:]]+Kbytes/,e){print e[1]}'
1 Like
awk '{print $(NF-2)}'
1 Like