1

I am working to create a shell script to return iNode usage from a Solaris box.

The command I use to run is: df -F ufs -o i,

and say the output is:

    Filesystem             iused   ifree  %iused  Mounted on
    /dev/dsk/c1t0d0s1     248503 3443913     7%   /

The only part I need to catch is 7%. Please help me on the part that returns the %iused, and output it at the end of the script.

Thanks in advance!

Regards,

Madean

Jens
  • 69,818
  • 15
  • 125
  • 179
Madean
  • 129
  • 1
  • 2
  • 9

4 Answers4

0
set `df -F ufs -o i`
printf '%s\n' ${10}

This works as long as the df output is exactly as you've shown. If it actually has more lines and you are only interested in the root file system /, then use df ... / to make it output only the stats you are interested in.

Jens
  • 69,818
  • 15
  • 125
  • 179
0
df -F ufs -o i | nawk 'NR>1 {print $4}'
jlliagre
  • 29,783
  • 6
  • 61
  • 72
0

Use this.

df -F ufs -o i | sed -n '$p' | awk '{print $4}'
Baby Groot
  • 4,637
  • 39
  • 52
  • 71
Faiz
  • 1
0

df -F ufs -o i | grep ^/ | awk '{print $4}'

Gili
  • 86,244
  • 97
  • 390
  • 689
Sabarish
  • 23
  • 1
  • 10