How to format grep statement?

I have a grep command that looks through the maillog and tells me how what source IPs are logging in to email.

The problem is that the output  has no <CR><LF>s in the file so it is a huge runon sentence. I am looking for the additional syntax that will at least give a <CR><LF> after every line, or a <br /> since I am looking at this file from a url link.  It would also be nice to have a blank line after every email address group.

This is my grep statement:
grep 'pop3-login' /var/log/maillog | grep ': Login: user' | sed -e 's/.*user=<//' -e 's/>.*rip=/ /' -e 's/, lip.*$//' | sort | uniq -c >/home/domain/public_html/email_logins.html

This is what I get:
12 xxx.228.235.254 1 xxx.134.196.144 524 xxx.14.122.184 523 xxx.78.29.0 5551 xxx.83.195.76 1061 xxx.110.64.230 302 xxx.197.96.69

This is what I would like to see:

12 xxx.228.235.254
1 xxx.134.196.144
524 xxx.14.122.184

523 xxx.78.29.1
5551 xxx.83.195.76

1061 xxx.110.64.230

302 xxx.197.96.69

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.

... | uniq -c | sed 'a<br>' >/home/domain/public_html/email_logins.html

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
after the uniq -c add
| awk ' { print $1,$2,$3,"\n"}' >> to your file
You can try to replace the carriage return and the line feed with a blank line.

perl -pi -e 's/\r\n/\n/g'

Open in new window

The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

did not notice that you were outputing to an html page.
from a security point of view do you really want to publish your email addresses?

write to a .txt file instead of html
ozo is right

given then fact hat sort and uniq work, your file is multi-line

several options there

1) html-ize the file
.... uniq -c | sed 's/$/<br>/' >> output file

2) have your web server print the file as text and not html. since any decent web server would do it automagically, i assume you have some kind of script that sends the file to the client. you'd need to instruct it to print a text/plain header and check for line endings if you expect to view it on windows. you can stick unixtodos or tofrodos in the pipe if you need to change line endings

3) you can print the output between <pre>...</pre>
jasgotAuthor Commented:
PERFECT! Thank you.
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.