最近在做LFS的时候,发现了几个sed命令有些怪。
wangyao@fisherman:~$ cat file
/home/wangyao
wangyao@fisherman:~$ sed 's@/home/wangyao@/home/wangyao/bin@' file
/home/wangyao/bin
wangyao@fisherman:~$ sed 's/\/home\/wangyao/\/home\/wangyao\/bin/' file
/home/wangyao/bin
使用@符号,就可以不用解析匹配项的元符号了。
wangyao@fisherman:~$ sed 's@home\/wangyao@/home/wangyao/bin@' file
//home/wangyao/bin
wangyao@fisherman:~$ sed 's@\/home\/wangyao@/home/wangyao/bin@' file
/home/wangyao/bin
wangyao@fisherman:~$ sed 's@\/home\/wangyao@\/home/wangyao/bin@' file
/home/wangyao/bin
使用@后,转义/为\/跟不转义的效果是一样的。
阅读(2090) | 评论(0) | 转发(0) |