我需要让 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
等提前谢谢。
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*.*
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.