awk command

I have a very large log file and need to find all lines with a certain statement in it, there is many of them repeating, I need to get it to work with and without uniq lines.

here is a example of one of the lines I'm looking for,    the key that is in each line is  ( Connection refused )

30-Nov-2004 08:20:05.76 tcp_intranet              Q 8 rfc822; /opt/iplanet/ms5/msg-hampton/queue/tcp_intranet/005/Z60I7W00.00 <> mailsrv  TCP active open: Failed connect()    Error: Connection refused

I can find these lines with grep but I want to find these lines and only print the columns  5 and 6 and the   Error: Connection refused

Who is Participating?
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.

bt707Author Commented:
also is there a way to use uniq and only print out one line of all the duplicate lines but get a number of how many times a duplicate line was in the file.

bt707Author Commented:

I have it about working using this

awk '$18 ~ /refused/ {print $6, $7, $16, $17,$18}' log_files | uniq

however i'm still for a way to print to screen one copy of the duplicate lines but get a number of how many times the duplicate lines was in the file,

any sugestions,

Does this do what you want?
awk '$18 ~ /refused/ {print $6, $7, $16, $17,$18}' log_files |sort |uniq -c

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
bt707Author Commented:
Thanks tfewster worked Great,

Thanks again,
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
Unix OS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.