[英]Understanding a Sed command
I am modifying some shell script and came across this command. 我正在修改一些shell脚本,并遇到了此命令。
sed -i "s@demo.testcase.com@$hostname@g" configuration.xml
I searched and found out the sed with s option is just a substitution. 我搜索了一下,发现sed和s选项只是一个替代。 And the g at the end stands for global. 最后的g代表全局。 But I can't find what @ symbol are for. 但是我找不到@符号的作用。
Can anybody explain the above command to me? 有人可以向我解释以上命令吗?
Thanks 谢谢
The symbol immediately following s
is the command/argument delimiter. 紧跟s
的符号是命令/参数定界符。 Traditionally, /
is the most commonly used but it can be other symbols, like @
as well. 传统上, /
是最常用的符号,但也可以是其他符号,例如@
。
If you like to replace this: 如果您要替换为:
/some data/
with this: 有了这个:
/some other/data
You can do this and escape the /
您可以执行此操作以使/
sed "s/\/some data\//\/some other\/data/g"
or change the /
to some else: 或将/
更改为其他:
sed "s@/some data/@/some other/data@g"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.