I'm reasonably new to shell scripting, so I've had difficulty applying the answers to similar questions to my problem.
I am trying to ssh to a remote server, perform multiple awk commands, and return the value of each to a local .txt file. I am also trying to ssh to other servers, perform similar commands, and return them to the same text file.
If i manually ssh into the remote server and run df -h | awk '$6 == "/" {print $5; exit} I get the % used value for the root directory from the df -h command.
Thus far, I have the following, but while it enters and exits the remote server it doesn't save the value.
> testfile.txt
ssh {$CURRENT_ENV} << EOF
VAL=\$(df -h | awk '\$6 == "/" {print \$5; exit}')
echo "\$VAL > testfile.txt"
exit
EOF
I've looked at single line awk returns, but as I have multiple commands to run it doesn't seem optimal. I would appreciate any suggestions!