using awk remotely

Hi there

I am trying to add up the disk space used on a remote linux box but am falling at the first hurdle i.e isolating the 'space used' column with df -k on the remote box

if i run this, i get the df -k output as expected

# rsh remote-server 'df -k|grep sd|grep -v boot' 
/dev/sda3              8254272   1672956   6162020  22% /
/dev/sdb4            140258988  13405152 119729012  11% /data
/dev/sda4            123648020     32828 117334180   1% /data1 

which is fine, however I want to isolate the third column, so that i can add use some additional logic to add the values to give me a total space used by that box

so i tried

# rsh remote-server 'df -k|grep sd|grep -v boot|awk {print $3} '
awk: cmd. line:2: (END OF FILE)
awk: cmd. line:2: parse error

I tried using cut, but setting the delimiter to " " (ie space) it messes up all the columns

does anybody have any idea how i can get around this ?

any help would be great

try this:

rsh remote-server "df -k | grep sd | grep -v boot | awk '{print $3}'"

Or maybe this might help,

rsh remote-server <<'EOF'

   df -k | awk '/sd/ && !/boot/ { print $3 }'

EOF

... And awk has its own search capabilities.

yea awk has its own search capability but grep is much faster than awk..
this is my personal experience:)

I tried the double quote option and I got this

# rsh remote-server "df -k | grep sd | grep -v boot | awk '{print $3}'"
/dev/sda3              8254272   1672772   6162204  22% /
/dev/sdb4            140258988  12922912 120211252  10% /data_store
/dev/sda4            123648020     32828 117334180   1% /data_store1

i.e. it didnt print column 3 on its own!

unfortunately I got this

# rsh remote-server <<'EOF'
> df -k | awk '/sd/ && !/boot/ { print $3 }'
> EOF
tcgetattr: Inappropriate ioctl for device
ioctl I_FIND ttcompat: Inappropriate ioctl for device

any other suggestions ?

Yes:

rsh host 'df -k | awk "/sd/ && !/boot/ { print \$3 }"'

thats fantastic

now i just need to find a way of adding them up, thanks again for all your help guys

rsh host '
  df -k | 
    awk "/sd/ && !/boot/ { t += \$3; print \$3 }  
      END { print \"Total:\", t }"
      '

wow, thank you very much