LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to truncate mailq command output (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-truncate-mailq-command-output-4175428194/)

shivaa 09-20-2012 06:52 AM

How to truncate mailq command output
 
Hello, as I hope all you're aware of output from "mailq" command.
For your information, it gives output in 3 rows, for example:

.......
........

22713127A18 2798 Thu Sep 10 11:01:24 MAILER-DAEMON
(connect to system.test.com[167.129.51.11]: Connection refused)
appmgr@system.test.com

28B60127A19 2798 Thu Sep 10 11:11:29 MAILER-DAEMON
(connect to system.test.com[167.129.51.11]: Connection refused)
appmgr@system.test.com
....
......
.......

So now I just want to list out recipient adresses (which are in 3rd row of every column of the output), so how can I achieve that?
Thanks in advance

Tinkster 09-20-2012 01:45 PM

I can think of several ways; the simplest is to grep for @.

Slightly more complex but relying on structure rather than
content:

awk '{printf "%s\n",$3}' RS="\n\n" FS="\n"


All times are GMT -5. The time now is 06:06 PM.