Home Linux Community Forums Software Command Line help on regular expression

help on regular expression

Link to this post 29 Apr 13

I want to extract some URLs of a txt file with grep --only-matching and regular expression.

I know only some info about the URL, but I definitely know by what it is enclosed.

so I use grep -o AA.*BB myfile.txt

But this gives my whole expression (i.e. AA"$URL"BB), but I only want the URL i.e. what is enclosed by AA and BB, how do I do that?


Link to this post 12 May 13

sed 's/AA\(.*\)BB/\1/g' myfile.txt

Link to this post 14 May 13

Mfillpot, some help please

Link to this post 16 May 13

Rather than reposting data that is already on the net, I recommend checking out some of the posts at

In addition you may be able to find some other scripts that can help at

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Linux Training / Board