I am trying to use awk to sum the outputs from a df –k on second column.
Here is what I have so far:
df -k |nawk 'BEGIN {NR > 1 }{ sum +=$2} END {print "\n Total diskspace in Kbytes: " sum }'
The problem is that this does not seem to sum correctly. It’s missing the last row from the df output for some reason. I placed the NR >1 to skip the first line of out put from the df command. This is a title line. I don't even know if that's correct.
Any suggestions would be great.
Here is what I have so far:
df -k |nawk 'BEGIN {NR > 1 }{ sum +=$2} END {print "\n Total diskspace in Kbytes: " sum }'
The problem is that this does not seem to sum correctly. It’s missing the last row from the df output for some reason. I placed the NR >1 to skip the first line of out put from the df command. This is a title line. I don't even know if that's correct.
Any suggestions would be great.