Instead of using | to pipe the output of df to awk I would use this
Code:
< <(df -lP) awk '..awk stuff here ..'
Probably makes little difference here, but using that instead of | means you don't have awk in a subshell ( instead df is in the subshell, and its output is passed to awk )
A better example is a while read loop
Code:
unset Array Array2
while read a;do Array+=($a);done < <(df -l --output=avail);echo ${Array[@]}
df -l --output=avail|while read a;do Array2+=($a);done ;echo ${Array2[@]}
In the first, the bash array 'survives', where as the second it is lost
Anyway
You will almost certainly want to apply either in conjunction with a passwordless ssh login, using public keys
Example
Code:
for Server in Server1 Server2 Server3;do
echo $Server free = $(ssh User@${server} "awk '/dev/{total+=$4} END {printf "%d", total/2^20 + 0.5}' < <(df -lP)")
done