字串代換 's'
|
's'字串代換,與 ex 中的代換功能差不多,格式如下:
|
在 Shell script 中使用 Sed, 可以將shell 變數用於 sed script 中,很有彈性;例如
|
sed 中的字串代換指令所用的分隔符號,可以使用任意字符。
|
習慣上最常用的符號是"/",如果要替換的字串中含有此符號就很不方便,例如下面的例子
要把字串 Dir1/Old 改成字串 Dir2/New:
|
如果改用其他符號,如下例,就很方便了:
|
Multiple Editing Scripts in Sed
|
| |
---|
the '&' in the replacement part means reusing 'pattern' here
the '/' separator, in fact could be ANY character.
| <flags> are optional, and can be combined
|
|
---|