sed替换写法sed

时间:2022-08-11 17:06:35

sed替换的两种写法,今天看脚本的时候遇到了一个没见过的写法:

用;替代/的

如下:

 

root@iZ2zegl8h62gwjeuf4d47lZ:~# echo "hello;nihao" | sed -e 's;\;;:;g'     #####   ;代替了 /  等同于下面的写法

hello:nihao

root@iZ2zegl8h62gwjeuf4d47lZ:~# echo "hello;nihao" | sed -e 's/\;/:/g'

hello:nihao