I am having difficulty on the command below. Something is not right with the awk command. I tried putting backslash but still no good. Anyone can pin point where is my syntax gone wrong?
for i in $(cat db_hostlist2.txt | grep -v '^#'); do
echo "Checking for $i";
ssh admin@$i '
. ./.bashrc; echo "Hostname : `hostname`";
echo -e "Total DB is : `ps -ef | grep smon | grep -v grep | wc -l`\n";
echo -e "Total DB is : \n`ps -ef | grep smon | grep -v grep |awk -F_ '{print $3}'`\n"
';
done
Output:
Hostname : TEST123
Total DB is : 3
awk: cmd. line:1: {print
awk: cmd. line:1: ^ unexpected newline or end of string
Total DB is :
'
interferes with ssh's'
try escaping those with \ – YoMismo Sep 1 at 8:38