![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| grep regular expression | Calypso | Shell Programming and Scripting | 7 | 05-18-2009 08:08 AM |
| grep with regular expression | daikeyang | Shell Programming and Scripting | 6 | 03-22-2009 08:46 PM |
| How can we grep only those content according to regular expression | Johnivy | UNIX for Dummies Questions & Answers | 3 | 12-16-2008 08:43 AM |
| regarding grep regular expression | ukatru | UNIX for Advanced & Expert Users | 2 | 10-23-2008 12:47 AM |
| grep : regular expression | RishiPahuja | Shell Programming and Scripting | 10 | 09-13-2005 01:53 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Regular expression in grep -E | awk print
Hi All, I have file.txt with contents like this: random text To: recipient@email.co.uk <HTML>S7randomtext more random text random text To: recip@smtpemail.com <HTML>E5randomtext more random text random text I need the output to look like this: 1,,,1,S7 1,,,1,E5 My code so far is: Code:
grep -E "[A-Z][0-9]" file.txt | awk '{print ",1,,,1,"[A-Z][0-9]}' > out.txt
but I get this error: awk: line 1: syntax error at or near [ How can I get the Regular Expression [A-Z][0-9] into the print of awk??? Please help asap Last edited by terry2009; 10-02-2009 at 05:41 AM.. |
|
||||
|
Quote:
regards |
|
||||
|
It's a literal > (meaning match a greater-than sign, or in this context an angled bracket)
|
|
||||
|
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. |
![]() |
| Bookmarks |
| Tags |
| awk, expression, grep, print, regular |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|