grep a url on a specific line

I'm grepping spam from my application logs.

I'm looking for the one line URL spam.  It will always show up on my third line


How do I grep only the third line and how to I grep to see if a URL exists?

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

md168Author Commented:
I figured out how to find the specific line: head -3 spam.txt | tail -1

Now, I need to search for a URL


STRING=`head -3 $LOG_FILE | tail -1`
if [ "$STRING" =~ "http" ]
   echo $STRING

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Try this one

sed -n 3p spam.txt | grep http

Open in new window

10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

Or try this one even simpler and more efficient
sed -n  3,/http/p

Open in new window

md168Author Commented:
I couldn't get the sed to work.  I'll use the wesly's script.  Thanks.
Both the sed work

What is the error message
Hi farzanj, I believe your second one is
sed -n 3,/http/p spam.txt
Hi Wesly,
Yes, I forgot the file name but the first one worked too.  It had filename as well.  And both DO work.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.