When I run df -h I see:/dev/sda2                     46G  3.2G   41G   8% /udev                          24G  4.0K   24G   1% /devtmpfs                        9.5G   10M  9.5G   1% /runnone                         5.0M     0  5.0M   0% /run/locknone                          24G     0   24G   0% /run/shm/dev/mapper/DG9999-lvDG9999   82T   75T  7.5T  91% /DG9999/dev/sda3                     20G  445M   19G   3% /homeclamfs                        82T   75T  7.5T  91% /DG9999/clamfsI'm using this command: df -h / | grep -v Filesystem | awk '{print $5}' | sed 's/%//g'At the moment the output shows me the 5th column in the first line of the df -h output which is 8. How can I specify that I am interested in the 6th line of the output so that the output shows 91.Thanks
Print specific row with awk from output of df -h
linux;awk;grep
You need to specify the appropriate file system (or mount point):df -h /DG9999 | grep -v Filesystem | awk '{print $5}' | sed 's/%//g'When parsing dfs output on most Linux systems, you should use the -P option to ensure that each file systems information is kept on a single line:df -hP /DG9999 | grep -v Filesystem | awk '{print $5}' | sed 's/%//g'You can combine all the output manipulation to use just AWK:df -hP /DG9999 | awk '!/Filesystem/ { print substr($5, 1, length($5) - 1) }'On any recent GNU setup you can also rundf --output=pcent /DG9999 | sed '1d;s/%//'