The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 08-30-2007
wally_welder's Avatar
wally_welder wally_welder is offline
Registered User
  
 

Join Date: Aug 2007
Location: Dongen, Netherlands
Posts: 2
capturing line from script output and appending to a file

Hi all,
I did some searching in this forum but can't find anything that matches the issue I'm bumping heads with.

On a CentOS4/Postfix (and bash everywhere) mail gateway box I run a command periodically to purge the Postfix queue of messages "From:MAILER-DAEMON".

This is the one line'r (courtesy of the Postfix list archives)

Code:
mailq | grep -v "^[^0-9A-Z]+" | grep MAILER-DAEMON | awk '{print $1}' | postsuper -d -
This generates output exactly as shown:
[many preceding lines of exactly the same format]
postsuper: E657736C82BD: removed
postsuper: E1CAD36C8074: removed

and finally, at the end of the output:
postsuper: Deleted: 127 messages

What I'm trying to figure out how to do is this.....
Grab the number of deleted messages, and append them to a file with a timestamp e.g. 20070830 07:32 - 127

so somewhere in the latter end of this would be >> cron_purges

Can anyone help me understand how to grab *just* the number, and hang a timestamp onto it as shown in the above example?

Regards & TIA!
Wally