I’m having issues implementing this awk statement that I need for my script:
rsh fooDNS '
...
BROADCAST_IP_ADDRESS=$(/usr/sbin/ifconfig $IF_NAME | grep broadcast | awk '{print \$6}')
...
'
The issue here is that the statement above is contained within an rsh command surrounded by single quotations. Consequently, bash cannot interpret the single quotations around {print $6}, which is giving me a lot of problems. So far, I haven’t been able to determine how to get around this issue.
You can’t nest single quotes, but you can end the single quoted string, include an escaped single quote, and then re-enter the quotes. Try this:
Nonetheless, this kind of quoting madness gets ugly very quickly. If at all possible, I recommend using scp/rcp/ftp to copy a normal bash script over to the remote and then run that. Failing that, I think you can use a trick like this if you don’t need to feed anything to the script’s stdin:
(Use
rsh fooDNS /bin/shif your script is plain-sh-compatible and the remote side doesn’t have bash, of course.)As yet another alternative, if your snippet is short you can use here docs: