我遇到以下问题:我试图取消注释我确定使用的特定行:
LINESTART=$(grep -nr "matching string" test.conf | cut -d : -f1)
Run Code Online (Sandbox Code Playgroud)
之后我需要取消注释该代码$LINESTART部分$((LINE+10))
LINEEND=$((LINE+10))
Run Code Online (Sandbox Code Playgroud)
我尝试了以下 sed 语法:
sed -i '${LINESTART},${LINEEND} s/# *//' test.conf
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误:
sed: -e expression #1, char 4: extra characters after command
Run Code Online (Sandbox Code Playgroud)
示例 test.conf:
84 #server {
85 # listen 8000;
86 # listen somename:8080;
87 # server_name somename alias another.alias;
88
89 # location / {
90 # root html;
91 # index index.php index.html index.htm;
92 # }
93 #}
Run Code Online (Sandbox Code Playgroud)