Extract certain patterns from file.

Hi All,

I tried extracting this pattern using grep but it did not work.

What I have is a file which has contents like this:

file:///channel/add-adhd.html
file:///channel/allergies.html
file:///channel/arthritis.html
http://mail.yahoo.com/
http://messenger.yahoo.com/
http://news.yahoo.com/
http://shine.yahoo.com/
https://twitter.com/YahooHealth
IMG
My Yahoo!
Yahoo! Finance
Yahoo! News
Yahoo! Sports

Now what I want to do is to extract all http, https, and file patterns or lines and get rid of IMG, My Yahoo!, Yahoo! News etc. This means my final output should like this:

file:///channel/add-adhd.html
file:///channel/allergies.html
file:///channel/arthritis.html
http://mail.yahoo.com/
http://messenger.yahoo.com/
http://news.yahoo.com/
http://shine.yahoo.com/
https://twitter.com/YahooHealth

Doing:

more file_name | grep http

extracts lines containing "http". But I want to extract all the three patterns by somehow nesting grep. I even tried this:

more file_name | grep http | grep https | grep file

But it did not work. I am using Linux with Bash.

egrep 'http|https|file' file_name
1 Like

that should e like below.
code :
egrep 'http|https|file' file_name

regards
rajesh

1 Like