【发布时间】:2014-07-09 08:16:50
【问题描述】:
我知道有人已经要求类似的东西,但我无法在远程主机中使用该命令。我有 bash:
#!/bin/bash
IMSI="732111030120252"
ssh openbts@192.168.10.12 bash -c " '
sed -i '61,$d' /etc/asterisk/sip.conf #erase the lines fron 61 to end of the file sip.conf
sed -i '288,$d' /etc/asterisk/extensions.conf
echo "[IMSI$IMSI].(sets)" >> /home/openbts/Desktop/Prueba #Write that expression inside Prueba (Ignore .)
' "
但是,他正在考虑将 $d 和 () 视为局部变量,而不是 sed 和 echo 命令的一部分。
我发现您可以使用 \\\$d 或 echo 中的所有行,但它们不起作用。
有人有想法吗??谢谢
【问题讨论】:
-
变量在双引号内展开。将命令放在单引号中,它们不会在本地展开。