By connecting via ssh, you must run the script on the remote machine. Can't figure out sed. Or rather, how it interacts with the transmitted variables
Example:
#!/bin/bash # A=«java.extended.prop=-XX\:NewSize\=1024m -XX\:MaxNewSize\=1024m -XX\:PretenureSizeThreshold\=10m» ssh root@10.2.200.172 " B=\$(echo $A | cut -d «=» -f 2-) touch /tmp/test.txt echo «java.extended» > /tmp/test.txt cat /tmp/test.txt sed -i '/java/a \$B' /tmp/test.txt cat /tmp/test.txt "
The result of the work will be as follows:
java.extended $ B
How to correctly transfer sed to a variable computed on a remote machine in order to get the record I need?
What should happen:
java.extended -XX: NewSize \ = 1024m -XX: MaxNewSize \ = 1024m -XX: PretenureSizeThreshold \ = 10m