I have the following block of code in my file:
175 MY_IP=`ifconfig eno1 | grep netmask | tr -s ' ' | cut -d " " -f 3`
176 echo "" > /home/hadoop/.ssh/config
177 cat > /home/hadoop/.ssh/config <<EOF
178 Host `echo $MY_IP | sed 's/.[0-9][0-9]*$//g'`.* 0.0.0.0 master worker*
179 StrictHostKeyChecking no
180 UserKnownHostsFile=/dev/null
181 EOF
I expect lines 178 to 181 to just be written to a file, but I get this error output:
/script.sh: line 178: unexpected EOF while looking for matching `''
/script.sh: line 184: syntax error: unexpected end of file
Why is it not just copying that text instead of checking its syntax?
Update: The way my code and error messages look right now:
175 MY_IP=`ifconfig eno1 | grep netmask | tr -s ' ' | cut -d " " -f 3`
176 echo "" > /home/hadoop/.ssh/config
177 cat > /home/hadoop/.ssh/config <<EOF
178 Host `echo $MY_IP | sed "s/.[0-9][0-9]*$//g"`.* 0.0.0.0 master worker*
179 StrictHostKeyChecking no
180 UserKnownHostsFile=/dev/null
181 EOF
182
183 chown -R hadoop:hadoop /home/hadoop
/script.sh: line 175: unexpected EOF while looking for matching `''
/script.sh: line 184: syntax error: unexpected end of file
Solved: After reviewing my code, I found a missing single quote in one of the very first lines. Pairing it with another solved the issue.
's/..//g'
)