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=
精彩评论