help with grep and mailx


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers help with grep and mailx
# 1  
Old 11-16-2004
help with grep and mailx

I have a huge file that I want to grep for the following:

the word "SEVERE" and today's month and date (Nov 16)

I then want to send the results of this grep to someone using mailx, as an atachment.

My question is how can I do this in one single line?


Thanks in advance.

Last edited by ssmiths001; 11-16-2004 at 04:33 PM..
# 2  
Old 11-16-2004
check this out ....


cat testfile | grep "$(a=`date | cut -d" " -f 2,3`)" | grep "SEVERE" | tee file1 | uuencode file1 file1
| mailx X@Y.com
# 3  
Old 11-16-2004
Can you explain the syntax? I tried this and it didn't work, so I'm trying to breakdown each command to be clear what it does.

Thanks
# 4  
Old 11-16-2004
---> testfile is the 'HUGE' file u are mentioning abt ;

----> date | cut -d" " -f 2,3 gives Nov 16

---> grep "SEVERE" is grepping for the out put from prevoius pipe.



---> uuencode and mailx are used to send the file as attachement.

Please let me know what is err u are getting ;
# 5  
Old 11-16-2004
Tools

Following is more efficient than previous :


grep -e "$(a=`date | cut -d" " -f 2,3`)|SEVERE" testfile | tee file1 | uuencode file1 file1 | mailx X@Y.com
# 6  
Old 11-16-2004
sry for the previous one ...; it may not work ;


this will work :

grep "$(a=`date | cut -d" " -f 2,3`)" testfile | grep "SEVERE" | tee file1 | uuencode file1 file1 | mailx X@Y.com
# 7  
Old 11-16-2004
Quote:
Originally posted by bhargav
sry for the previous one ...; it may not work ;


this will work :

grep "$(a=`date | cut -d" " -f 2,3`)" testfile | grep "SEVERE" | tee file1 | uuencode file1 file1 | mailx X@Y.com
Use $(command) or the old `command` but $(a=`command`) is crazy. What do you expect that to do?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Inconsistent `ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l`

i have this line of code that looks for the same file if it is currently running and returns the count. `ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l` basically it is assigned to a variable ISRUNNING=`ps -eaf -o args | grep -i sfs_pcard_load_file.ksh |... (6 Replies)
Discussion started by: wtolentino
6 Replies

2. Shell Programming and Scripting

Help with Mailx

Hi , I have written below code to send email from unix. The code is getting executed fine but i am not receiving any e mail . I am not sure what is going wrong . Do we need to do any configration setting before using Mailx? Please help set -vx echo 'Sending Mail' mailx -s "SEPA_TEST"... (2 Replies)
Discussion started by: Chandru_Raj
2 Replies

3. Shell Programming and Scripting

Mailx: How to send a attachment using mailx command

Hi All, Can anyone please provide the command for sending an mail with attachment using mailx command. Thanks in Advance :) Regards, Siram. (3 Replies)
Discussion started by: Sriram.Vedula53
3 Replies

4. Shell Programming and Scripting

MEM=`ps v $PPID| grep -i db2 | grep -v grep| awk '{ if ( $7 ~ " " ) { print 0 } else

Hi Guys, I need to set the value of $7 to zero in case $7 is NULL. I've tried the below command but doesn't work. Any ideas. thanks guys. MEM=`ps v $PPID| grep -i db2 | grep -v grep| awk '{ if ( $7 ~ " " ) { print 0 } else { print $7}}' ` Harby. (4 Replies)
Discussion started by: hariza
4 Replies

5. Solaris

Using Mailx

I am new to Unix and i want to know when using mailx can we change the sender's name from the default one. (3 Replies)
Discussion started by: blackeyed
3 Replies

6. HP-UX

mailx help

Hi, I have a shell script which has code like: cat /tmp/MAIL_PCSD | mailx -m -s " PEWA Order Acknowledgement" $M1 and M1 is nothing but this M1=`echo $x | awk ' {print $3}' ` If I pass absolute email address to $M1 it works fine. But, the thing is that it gets $M1 by reading some... (3 Replies)
Discussion started by: isingh786
3 Replies

7. UNIX for Advanced & Expert Users

MAILX help

Hello all, how do I view the default mail configurations using the mailx problem? At the moment, I have an account, and all the mail to that account is being routed to an email address, how can I view this behaviour? Also, is there anyway I can view the default mail settings for a server without... (0 Replies)
Discussion started by: Khoomfire
0 Replies

8. UNIX for Dummies Questions & Answers

mailx error message : mailx: NUL changed to @

If I use the "Mail" link instead of the "mail" link to ../mailx I get this error. Mail so-n-so @whatever.com mailx: NUL changed to @ Unknown command: "postmaster" The email still goes through but i get the error. If I use "mail" it goes thru without the error. Any ideas?? (2 Replies)
Discussion started by: BG_JrAdmin
2 Replies

9. Shell Programming and Scripting

Mailx

I am trying to write a shell script using the mailx command. My problem is that I want to send an email address in the CC: field. What option can I use with mailx to accomplish this. Any help would be very appreciative. (1 Reply)
Discussion started by: skammer
1 Replies

10. UNIX for Dummies Questions & Answers

Need help with mailx

How can I send a file of Unix usernames to everyone on the file without making an alias in my .mailrc file? Using a mailx command. Thanks, J.J. (2 Replies)
Discussion started by: JJJ
2 Replies
Login or Register to Ask a Question