With the substitution command, we can handle 90% of the most frequent uses of sed. But there are so many features that we cannot miss it! Delimiter is one of them.

We can see the examples that use slash as the delimiter frequently when we are searching for the examples. But I think few people knows that we can use character as the delimiter. Let's see the examples now.

examples:

1.sed 's/\/etc\//\/myEtc\//g' paths

This example uses the slash as delimiter. Most of us love the slash because we use the slash in vi/vim, ed, more, less and so on. We may find the slash is everywhere. But it may not be a good idea to use it here. We call this command  'Picket Fence'. It is ugly to most of us.

2.sed 's_/etc/_/myEtc/_g' paths

In fact, we can use any character that we like. 

Someone uses '/' while others uses '_'. What's more, the sed won't be angry if you use ':' or ';'.

posted on 2012-09-28 12:22  Neoh  阅读(331)  评论(0编辑  收藏  举报