在SED变量 [英] variable in sed
本文介绍了在SED变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何使用一个变量作为取景器模式为sed的?例如:
how can I use a variable as a pattern finder for sed? for example:
sed -i '/$pc/ s/off/on/' ~/Documents/Mantenimiento
我知道有一个$之间的'',但有如此的方式!请大家帮忙!
I know there is a $ in between the '' but there gotta be a way! please help!
推荐答案
使用双引号,而不是单引号,或者只是变量之前关闭的报价并重新打开他们之后。
Use double quotes instead of single quotes, or close the quotes just before the variable and reopen them just after.
sed -i "/$pc/ s/off/on/"
sed -i '/'$pc'/ s/off/on/'
这将让bash的正常进行可变评价。
This will let bash perform the variable evaluation normally.
这篇关于在SED变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文