Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 09-20-2012, 07:52 AM   #1
Senior Member
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
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[]: Connection refused)

28B60127A19 2798 Thu Sep 10 11:11:29 MAILER-DAEMON
(connect to[]: Connection refused)

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

Last edited by shivaa; 09-20-2012 at 07:55 AM.
Old 09-20-2012, 02:45 PM   #2
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917
I can think of several ways; the simplest is to grep for @.

Slightly more complex but relying on structure rather than

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


awk, command, mailx, sed

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Requests to my ISP server are output in the middle of output by any command I run. stf92 Slackware 2 07-10-2012 09:38 AM
[SOLVED] truncate shell command puth Programming 5 03-18-2010 11:49 AM
How to redirect the output of exec command output in perl? sudhap85 Linux - Newbie 3 08-28-2009 04:35 PM
Grep on output of command returns all output traigo Linux - Newbie 2 02-24-2009 06:15 PM
truncate command butthead Linux - General 1 05-14-2002 04:40 AM > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration