When I ssh into a server and run the command, it works:
$ssh -q postgres@XXXXX
Last login: Mon Mar 12 12:30:16 2018 from 10.101.XXX.X
[postgres@pgsdba203 ~]$ df -hP | grep pgsql | awk '{ if ($5 >= 70) print $0 }'
/dev/mapper/pgvg-pg_log 9.9G 7.2G 2.2G 77% /var/lib/pgsql/data/pg_log
But not when it's part of an ssh command parameter:
$ ssh -q postgres@XXXXX "df -hP | grep pgsql | awk '{ if ($5 >= 70) print $0 }'"
awk: { if ( >= 70) print -bash }
awk: ^ syntax error
Since the awk command is in single quotes, I'd have expected the $5
to be preserved and passed directly to server XXXXX.
EDIT: the end goal is to make the server name into a variable and call ssh from within a bash for loop.