0

我需要让 sed 替换很多文件中的一些 url。每个文件都有以下内容

 http://www.expample.com/file.php?id=xxxxxxx

其中xxxxx包括随机数,每个文件中的随机深度,如

file 1

_h**p://www.expample.com/file.php?id=xx

file 2

_h**p://www.expample.com/file.php?id=xxxxxxxx

等提前谢谢。

4

2 回答 2

1

As the comments say you will need to tell us what you want to replace them with.

But in the mean time something to chew on

sed s/id\=[0-9]+/id\=/     file*.*

if they are hex digits

sed s/id\=[0-9A-Fa-f]+/id\=/     file*.*
于 2009-06-17T17:49:25.857 回答
0
sed -e "s/(http:\/\/www\.example\.com\/file\.php\?id=\d+)([^\d]|$)/YOUR_REPLACEMENT\2"

should do it... Untested though, I'm sitting at a sed-less Windows box right now.

于 2009-06-17T17:46:44.380 回答