linux - How to use single quotes inside awk statement that is surrounded by single quotes? -


I'm having problems implementing this AKC statement for which I need my script: < Pre> Rsh fooDNS '... BROADCAST_IP_ADDRESS = $ (/ usr / sbin / ifconfig $ IF_NAME | grep broadcast | awk' {print \ $ 6} ') ...' < P> The issue here is that the above statement is contained in the RS command surrounded by a single quote. Consequently, bash can not interpret a quotation around $ 6}, which is giving me many problems. So far, how do I get this problem?

You can not nest single quote, but you can end single quoted string, one survives You can include a single bid, and then enter the quote again. Try it out:

  rsh fooDNS '... BROADCAST_IP_ADDRESS = $ (/ usr / sbin / ifconfig $ IF_NAME | grep broad | awk' \ '{print $ 6}' \ ''). . '  

However, this kind of craziness becomes ugly very soon. If possible, I recommend using scp / rcp / ftp to copy a normal Bash script into remote and then run it. If you do not believe this, I think you can use this kind of trick if you do not have to feed anything from the script:

  cat script_file | Use Rsh fooDNS bash   

( rsh fooDNS / bin / sh if your script is simple - sh - compatible and remote side Certainly not bash.)

As one more option, if your snippet is low then you can use Docs here:

  rsh fooDNS sh & Lt; & Lt; 'EOF' ... BROADCAST_IP_ADDRESS = $ (/ usr / sbin / ifconfig $ IF_NAME | Grep broadcast | awk '{print $ 6}') ... EOF    

Comments