开发者

Sed Search And Replace Question

What I can do if I want the "sed" to give me this ID as final result: b7f6fe86

The input might be http://www.uploading.com/files/b76f5e86/开发者_StackOverflow中文版hcadssoto720.part1.rar OR http://uploading.com/files/b76f5e86/hcadssoto720.part1.rar and I want the output to give the ID of this link.

For instance

echo http://uploading.com/files/b76f5e86/hcadssoto720.part1.rar | sed 's/SOMETHING/SOMETHING/g"

OUTPUT: b7f6fe86

echo http://www.uploading.com/files/b76f5e86/hcadssoto720.part1.rar | sed 's/SOMETHING/SOMETHING/g"

OUTPUT: b7f6fe86

I hope to get the help of regular expression experts. Cheers


cut -d'/' -f5

Should do it afaik.


try:

echo "http://uploading.com/files/b76f5e86/hcadssoto720.part1.rar" | sed 's|\([^/]*/\)\{4\}\([0-9a-f]*\).*|\2|'

Note that the '/' character is replaced by the '|' character to simplify the appearance of "leaning toothpick syndrome".

Bah - can't make some '*' appear properly - ah - got it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜