开发者

pattern after match

$string = "http://192.168.0.1/?url=http://www.google.com/?hl=";

how to return only

htt开发者_开发技巧p://www.google.com/?hl=

by use linux command


If your test string is truly in a shell variable named string then its as easy as this:

$ string="http://192.168.0.1/?url=http://www.google.com/?hl="
$ echo ${string#*=}
http://www.google.com/?hl=

If you really intend to use a unix command then I would suggest either perl or sed. Perl has the advantage of being able to use the non-greedy qualifier.

With perl

$ echo "http://192.168.0.1/?url=http://www.google.com/?hl=" | perl -pe 's/.*?=//'
http://www.google.com/?hl=

With sed

$ echo "http://192.168.0.1/?url=http://www.google.com/?hl=" | sed 's/[^=]*=//'
http://www.google.com/?hl=
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜