Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在sed命令中传递变量_Sed - Fatal编程技术网

如何在sed命令中传递变量

如何在sed命令中传递变量,sed,Sed,如何将变量作为输入传递给sed命令而不是文件请参见下面的示例。我正在尝试使用该命令,但无法传递变量 test=$(I have shell script here which stores the value in test) 现在我想读取变量并删除找到值“xyz”的行 我试过的命令 sed -i /xyz/d “$test” 像这样处理您的var echo "$test" | sed '/xyz/d' sed '/xyz/d' <<< "$test" 还是像这样 ec

如何将变量作为输入传递给sed命令而不是文件请参见下面的示例。我正在尝试使用该命令,但无法传递变量

test=$(I have shell script here which stores the value in test)
现在我想读取变量并删除找到值“xyz”的行

我试过的命令

sed -i /xyz/d “$test”

像这样处理您的var

echo "$test" | sed '/xyz/d'
sed '/xyz/d' <<< "$test"
还是像这样

echo "$test" | sed '/xyz/d'
sed '/xyz/d' <<< "$test"
sed'/xyz/d'