title: syntax error near unexpected token `|'
body: <p>I try to write a bash code and I am using command substitution. My code is like:</p>
  
  <pre><code>#!/bin/bash
  
  IP="10.0.0.1 10.0.0.2"
  PORT="22 80"
  USERNAME="admin"
  SCRIPT_HOST="adminHost"
  HOME_DIR=/home/admin
  SCRIPT_DIR=$HOME_DIR/scripts
  script="sudo /my_remote_script.sh"
  SSH="/usr/bin/ssh -t -o ConnectTimeout=10 -l ${USERNAME} ${SCRIPT_HOST}"
  
  declare -a array1
  declare -a array2
  declare -a array3
  
  
  for ip in ${IP} ; do
      for port in ${PORT} ; do
  
      rmt_command1=" $script -i $ip -p $port | awk -v IGNORECASE=1 '/pattern1/ {print \$4}' "
  
      rmt_command2=" $script -i $ip -p $port  | awk -v IGNORECASE=1 '/pattern2/ {print \$5}' "
  
      rmt_command3=" $script -i $ip -p $port | awk -v IGNORECASE=1 '/pattern3/ {print \$5}' "
  
      array1[$ip,$port]=$($SSH "$rmt_command1")
      array2[$ip,$port]=$($SSH "$rmt_command2")
      array3[$ip,$port]=$($SSH "$rmt_command3")
  
      done
  done
  
  for ip in ${IP}
  
      for port in ${PORT}
      printf   ${array1[$ip,$port]}
      printf   ${array2[$ip,$port]}
      printf   ${array3[$ip,$port]}
  
  done
  </code></pre>
  
  <p>And I receive an error message like:</p>
  
  <pre><code>./test_sh: line 20: syntax error near unexpected token `|'
  ./test_sh: line 20: ` rmt_command1=" $script -i $ip -p $port | awk -v IGNORECASE=1 '/pattern1/ {print \$4}' "'
  </code></pre>
  
  <p>What could be wrong?</p>