Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

unix formatting incorrect on smartphone 3

Status
Not open for further replies.

rigstars2

Instructor
Dec 18, 2011
64
US
Need help with formatting. Formatting is messed up when I receive it on my smartphone. I prefer NOT to receive the email as an attachment.

Here's my code. I've tried to use cat and the sed commands. Doesn't appears to have any affect once it comes into my mail client.

netstat -an | grep LISTEN | grep -v '2525'|grep -v '8883'|grep -v '3338'|grep -v '631' | sed 'G'` | mail -s "$SUBJECT" "$MAILTO"

or

`cat ~/ports.txt` //cat seems to remove the newline when I pipe it to mail

Both code above shows the output as the 'current output' below

Current output on smartphone mail client is
tcp46 0 0 *5204 *.* LISTEN tcp47 0 0 *5204 *.* LISTEN

Wanted output is
tcp46 0 0 *5204 *.* LISTEN
tcp47 0 0 *5204 *.* LISTEN

 
I find that instead of using sed just grep -v grep to remove the command from the output

I've no smartphone to test with but with "sed" it appears to double space the output in an email client but with the "grep -v grep" the output is formatted without the extra spacing.



netstat -an | grep LISTEN | grep -v '2525'|grep -v '8883'|grep -v '3338'|grep -v '631' |grep -v grep |mail -s "$SUBJECT" $MAILTO


Worth a try?

Laurie.
 
Or shorter:

Code:
netstat -an | grep LISTEN | grep -Ewv '2525|8883|3338|631' | mail -s "$SUBJECT" $MAILTO

No point in grep -v grep when it's not a process listing?

Annihilannic
[small]tgmlify - code syntax highlighting for your tek-tips posts[/small]
 
That's worth a star Annihilannic, good tip

Old habits die hard and all that ......

Happy NY

Laurie.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top