Awk script

Hi all,

I can't see some of file systems capacity output with file system name using below script:

here is the df output:

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda3             15116868  11890900   2458064  83% /
/dev/sda1               101086     13517     82350  15% /boot
none                  32435708         0  32435708   0% /dev/shm
/dev/mapper/ffderora-gghlvora
                      28092588   5301140  21364404  20% /oracle
/dev/sdi1            114222112 107657120   6564992  95% /orad2
/dev/sdh1            228444256 215828000  12616256  95% /orad9
/dev/sdj1            228444256 215594592  12849664  95% /orad10
/dev/sdk1            228444256 215086688  13357568  95% /orad11
/dev/sdl1            228444256 172073280  56370976  76% /orad12
/dev/sdm1            228444256 209843648  18600608  92% /orad1
/dev/mapper/ffderora-gghlvora
                     280995708 195028872  71696128  74% /rads01

Here is my script:

df -k | grep -v /dev/shm | grep -v cdrom | awk '{print $6,$5}' | tr -d \%

and its output:

/ 85
/boot 15

/oracle
/orad2 95
/orad9 95
/orad10 95
/orad11 95
/orad12 90
/orad1 92

/rads01

As you can see above output, /oracle and /rads01 file-systems have no capacity output since they have one more line (double-line)

how can i fix it?

Regards,

same problem occurs with this:
df -k | awk '{print $6 $5}'

df -k | grep -v /dev/shm | grep -v /dev/cdrom | awk '{print $5,$4}'

output :
83% 2455472
15% 82350

/oracle 20%
95% 6564992
95% 12616256
95% 12849664
95% 13357568
76% 56370976
92% 18600608

/rads01 74%

Try:

awk 'NF>1&&NR>1{sub("%","");print $NF, $(NF-1)}'

Regards

The output for oracle and rads01 is splitted over two lines.
So for this filesystems, the Use% fiels is 4, not 5.

Try and adapt the awk command :

df -k | \
awk '
   ! ( /\/dev\/shm/ || /cdrom/ ) {
      sub(/%/, "");
      Use = (NF == 6 ? 5 : 4)
      print $(Use+1),$Use
   }  ' 

Jean-Pierre.

Franklin52 & aigles

Both of them work and you're great!!

Thank you so much!