用双引号" 在shell脚本中包住$()调用 解决sed命令报错问题
问题 在 Free.vps.vc 访问GitHub资源出错 用GithubProxy代理 用sed修改脚本内容 的过程中,发生一件奇怪的事情。 curl -L https://github.com/crazypeace/v2ray_wss/raw/main/install.sh | sed -E $(curl -L https://github.com/crazypeace/gh-proxy/raw/master/sed-E-para1) 正常执行,但下面这个就报错 curl -L https://github.com/crazypeace/v2ray_wss/raw/main/install.sh | sed -E $(curl -L https://github.com/crazypeace/gh-proxy/raw/master/sed-E-para) GitHub上面的文件内容分别为: sed-E-para1: s#(http.*github[^/]*/)#https://github.crazypeace.workers.dev/\1#g sed-E-para : s#(curl.*\.sh)([^/])#\1 | sed -E "$(curl -L https://github.com/crazypeace/gh-proxy/raw/master/sed-E-para)" \2#g; s#(http.*github[^/]*/)#https://github.crazypeace.workers.dev/\1#g 在TG上问了一圈之后, fscarmen https://t.me/fscarmen2 给出了解决方案,用双引用把 $() 调用包起来。 解决方案 curl -L https://github.com/crazypeace/v2ray_wss/raw/main/install.sh | sed -E " $(curl -L https://github.com/crazypeace/gh-proxy/raw/master/sed-E-para) "