grep output formating

A 5 star hangout for overworked and underpaid system admins.
Post Reply
Posts: 17
Joined: 2013/09/03 18:33:54

grep output formating

Post by tommyfrass » 2014/08/06 14:08:14

ll take any help I can get on this topic.

I am trying to get the output of this into anything other than an email filled with numbers, a .csv would be nice. I have tried many iterations piping to awk etc.. but I clearly lack the solid knowledge to pull this simple task off. Any help is appreciated, pointing to any learning materials is also appreciated.

The output on screen contains six columns, the output in the email is all mushed together information.

thanks for your help

tn1=$(asterisk -r -x "sip show peers" | grep ^XXX )
echo $tn1 >> /tmp/emailmessage.txt
SUBJECT="Here is the Information"
/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE
rm -f /tmp/emailmessage.txt

Posts: 405
Joined: 2014/01/30 20:38:28

Re: grep output formating

Post by drk » 2014/08/06 16:47:59

Try something like the following:

Code: Select all

T=`mktemp --tmpdir=/tmp msgXXXXXXXXXX.txt`
asterisk -r -x "sip show peers" | grep ^XXX  > $T
S="Here is the Information"
printf "See attached\n" | mail -n -s "$S" -a $T $U
rm -f $T

Post Reply

Return to “CentOS Social”