Sponsored Content
Top Forums Shell Programming and Scripting Regular expression in grep -E | awk print Post 302358301 by terry2009 on Friday 2nd of October 2009 04:24:29 AM
Old 10-02-2009
Hi Again!

Here is an extended part of the script... I'd like to be sure that sed will work instead of grep....
Code:
grep -l "search string in files I want" smtp*.tmp > email_filenames_list.txt ;
cat email_filenames_list.txt | xargs cat >> smtp_all_emails_logs.txt ;
sed '/[A-Z][0-9]/ s#.*>\([A-Z][0-9]\).*#,1,,,1,\1#' smtp_all_emails_logs.log > out.txt ;
grep "^To" smtp_all_emails_logs.txt | awk '{print ","$2}' > recipients.txt ;
paste out.txt recipients.txt

the grep line definately works, but would sed run through a massive list of emails that have all been put in one file (smtp_all_email_logs.txt) and print:
S7,1,,,1,recipient@email.co.uk
R2,1,,,1,recip@smtpemail.com
etc in AIX environment

Another quick question: how can I stop a carrage return/line feed being included after the recipients email address? Cause it's screwing up my spreadsheet.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

grep : regular expression

guys, my requirment goes like this: I have a file, and wish to filter out records where 1. The first letter is o or O and 2. The next 4 following letter should not be ther I do not wish to use pipe and wish to do it in one shot. The best expression I came up with is: grep ^*... (10 Replies)
Discussion started by: RishiPahuja
10 Replies

2. UNIX for Advanced & Expert Users

regarding grep regular expression

When i do ls -ld RT_BP* i am getting the following list. drwxrwx--- 2 user group 256 Oct 17 10:09 RT_BP809 drwxrwx--- 2user group 256 Oct 17 10:09 RT_BP809.O drwxrwx--- 2 user group 256 Oct 17 10:09 RT_BP810 drwxrwx--- 2user group 256 Oct... (2 Replies)
Discussion started by: ukatru
2 Replies

3. Shell Programming and Scripting

grep with regular expression

Hi, guys. I have one question, hope somebody can give me a hand I have a file called passwd, the contents of it arebelow: *********************** ... goldsimj:x:5008:200: goldsij2:x:5009:200: whitej:x:5010:201: brownj:x:5011:202: goldsij3:x:5012:204: greyp:x:5013:203: ...... (6 Replies)
Discussion started by: daikeyang
6 Replies

4. Shell Programming and Scripting

grep and regular expression

Hi, I am executing a svnlook command to check to see if the following line exists. I need a regular expression to represent the line. A /test/test1/qa/test2/index.html A /test/test1/qa/test3/test.jpg A /test/test1/qa/test3/test1.jpg A /test/test1/qa/test4/test.swf I just need to extract... (9 Replies)
Discussion started by: kminkeller
9 Replies

5. Shell Programming and Scripting

Help with grep / regular expression

Hi, Input file: -13- -1er- -1xyz1- -1xz12- -2ab1- -2ab2-- -143- Code: grep '^*\-' input.txt Wrong output: -13- -1xyz1- -2ab1- -2ab2-- (4 Replies)
Discussion started by: dragon.1431
4 Replies

6. Shell Programming and Scripting

How to print the extended regular expression ?

Hello, How to print the field separator in awk? please see the following code: cat a.txt a 1s 2s 3s 4s b 2s 4s $ awk 'BEGIN{FS==" "} {print $2 $3 }' te 1s2s 2s4s I want to get the following output : 1s 2s 2s 4s How to realize this ? $ cat te a 1s,,2s 3s ... (11 Replies)
Discussion started by: 915086731
11 Replies

7. Programming

Perl: How to read from a file, do regular expression and then replace the found regular expression

Hi all, How am I read a file, find the match regular expression and overwrite to the same files. open DESTINATION_FILE, "<tmptravl.dat" or die "tmptravl.dat"; open NEW_DESTINATION_FILE, ">new_tmptravl.dat" or die "new_tmptravl.dat"; while (<DESTINATION_FILE>) { # print... (1 Reply)
Discussion started by: jessy83
1 Replies

8. Shell Programming and Scripting

Grep + Regular expression or

Hi , I have few lines like A20120101.ANU.ZIP A20120401.ABC.ZIP A20120105.KJK.ZIP A20120809.JUG.ZIP A20120101.MAT.ZIP B20120301.ANU.XIP I want to filter by 1. Files starting with A and Ending With Z ( ^A.*.ZIP$) 2. And either ANU, or KJK or MAT in the file name. Hope my... (6 Replies)
Discussion started by: Anupam_Halder
6 Replies

9. Shell Programming and Scripting

Grep command to search a regular expression in a line an only print the string after the match

Hello, one step in a shell script i am writing, involves Grep command to search a regular expression in a line an only print the string after the match an example line is below /logs/GRAS/LGT/applogs/lgt-2016-08-24/2016-08-24.8.log.zip:2016-08-24 19:12:48,602 ERROR... (9 Replies)
Discussion started by: Ramneekgupta91
9 Replies

10. UNIX for Beginners Questions & Answers

Grep regular expression

I want to track only below: I am using below, but it doesn't work: (6 Replies)
Discussion started by: proactiveaditya
6 Replies
smtp(n) 							    smtp client 							   smtp(n)

__________________________________________________________________________________________________________________________________________________

NAME
smtp - Client-side tcl implementation of the smtp protocol SYNOPSIS
package require Tcl package require mime ?1.5.4? package require smtp ?1.4.5? ::smtp::sendmessage token option... _________________________________________________________________ DESCRIPTION
The smtp library package provides the client side of the Simple Mail Transfer Protocol (SMTP) (1) (2). ::smtp::sendmessage token option... This command sends the MIME part (see package mime) represented by token to an SMTP server. options is a list of options and their associated values. The recognized options are: -servers A list of SMTP servers. The default is localhost. -ports A list of SMTP ports. The default is 25. -client The name to use as our hostname when connecting to the server. By default this is either localhost if one of the servers is localhost, or is set to the string returned by info hostname. -queue Indicates that the SMTP server should be asked to queue the message for later processing. A boolean value. -atleastone Indicates that the SMTP server must find at least one recipient acceptable for the message to be sent. A boolean value. -originator A string containing an 822-style address specification. If present the header isn't examined for an originator address. -recipients A string containing one or more 822-style address specifications. If present the header isn't examined for recipient addresses). If the string contains more than one address they will be separated by commas. -header A list of keywords and their values (may occur zero or more times). -usetls This package supports the RFC 3207 TLS extension (3) by default provided the tls package is available. You can turn this off with this boolean option. -tlspolicy This option lets you specify a command to be called if an error occurs during TLS setup. The command is called with the SMTP code and diagnostic message appended. The command should return 'secure' or 'insecure' where insecure will cause the package to continue on the unencrypted channel. Returning 'secure' will cause the socket to be closed and the next server in the -servers list to be tried. -username -password If your SMTP server requires authentication (RFC 2554 (4)) before accepting mail you can use -username and -password to pro- vide your authentication details to the server. Currently this package supports DIGEST-MD5, CRAM-MD5, LOGIN and PLAIN authen- tication methods. The most secure method will be tried first and each method tried in turn until we are either authorized or we run out of methods. Note that if the server permits a TLS connection, then the authorization will occur after we begin using the secure channel. If the -originator option is not present, the originator address is taken from From (or Resent-From); similarly, if the -recipients option is not present, recipient addresses are taken from To, cc, and Bcc (or Resent-To, and so on). Note that the header key/values supplied by the -header option (not those present in the MIME part) are consulted. Regardless, header key/values are added to the outgoing message as necessary to ensure that a valid 822-style message is sent. The command returns a list indicating which recipients were unacceptable to the SMTP server. Each element of the list is another list, con- taining the address, an SMTP error code, and a textual diagnostic. Depending on the -atleastone option and the intended recipients, a non- empty list may still indicate that the message was accepted by the server. EXAMPLE
proc send_simple_message {recipient email_server subject body} { package require smtp package require mime set token [mime::initialize -canonical text/plain \ -string $body] mime::setheader $token Subject $subject smtp::sendmessage $token \ -recipients $recipient -servers $email_server mime::finalize $token } send_simple_message someone@somewhere.com localhost \ "This is the subject." "This is the message." REFERENCES
[1] Jonathan B. Postel, "SIMPLE MAIL TRANSFER PROTOCOL", RFC 821, August 1982. (http://www.rfc-editor.org/rfc/rfc821.txt) [2] J. Klensin, "Simple Mail Transfer Protocol", RFC 2821, April 2001. (http://www.rfc-editor.org/rfc/rfc2821.txt) [3] P. Hoffman, "SMTP Service Extension for Secure SMTP over Transport Layer Security", RFC 3207, February 2002. (http://www.rfc-edi- tor.org/rfc/rfc3207.txt) [4] J. Myers, "SMTP Service Extension for Authentication", RFC 2554, March 1999. (http://www.rfc-editor.org/rfc/rfc2554.txt) BUGS, IDEAS, FEEDBACK This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category smtp of the Tcllib SF Trackers [http://sourceforge.net/tracker/?group_id=12883]. Please also report any ideas for enhancements you may have for either package and/or documentation. SEE ALSO
ftp, http, mime, pop3 KEYWORDS
email, internet, mail, mime, net, rfc 2554, rfc 2821, rfc 3207, rfc 821, rfc 822, smtp, tls COPYRIGHT
Copyright (c) 1999-2000 Marshall T. Rose and others mime 1.4.5 smtp(n)
All times are GMT -4. The time now is 08:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy