Extract match cases


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Extract match cases
# 1  
Old 03-17-2012
Extract match cases

hi guys

i have a file like this which is contain more than 3000 records

i want to extract emails have Creation Date: : Wed, 14 Aug 2009 and their POP3 Last Login Date and WebMail Last Login Date is Thu, 01 Jan 1970

how can i could do that

for example in this sample i need first1@xyz.com and first3@xyz.com


PHP Code:
first1@xyz.com
    Creation Date
Wed14 Aug 2009 15:08:01 
    POP3 Last Login Date
Thu01 Jan 1970 03:30:00 
    IMAP Last Login Date
Thu01 Jan 1970 03:30:00 
    WebMail Last Login Date
Tue13 Mar 2012 15:23:20 
first2
@xyz.com
    Creation Date
Thu19 Jan 2012 21:24:26 
    POP3 Last Login Date
Thu01 Jan 1970 03:30:00 
    IMAP Last Login Date
Thu01 Jan 1970 03:30:00 
    WebMail Last Login Date
Fri16 Mar 2012 07:34:53 
first3
@xyz.com
    Creation Date
Wed14 Aug 2009 18:19:41 
    POP3 Last Login Date
Thu01 Jan 1970 03:30:00 
    IMAP Last Login Date
Thu01 Jan 1970 03:30:00 
    WebMail Last Login Date
Sat17 Mar 2012 09:52:26 
first4
@xyz.com
    Creation Date
Tue17 Jan 2012 14:29:31 
    POP3 Last Login Date
Thu01 Jan 1970 03:30:00 
    IMAP Last Login Date
Thu01 Jan 1970 03:30:00 
    WebMail Last Login Date
Wed07 Mar 2012 00:00:03 
first5
@xyz.com
    Creation Date
Tue17 Jan 2012 18:09:03 
    POP3 Last Login Date
Thu01 Jan 1970 03:30:00 
    IMAP Last Login Date
Thu01 Jan 1970 03:30:00 
    WebMail Last Login Date
Sat17 Mar 2012 10:05:03 
# 2  
Old 03-17-2012
What should be the "WebMail Last Login Date"? Because in you example it is March 2012 and you wrote that it should be "Thu, 01 Jan 1970"...
# 3  
Old 03-17-2012
Quote:
Originally Posted by bartus11
What should be the "WebMail Last Login Date"? Because in you example it is March 2012 and you wrote that it should be "Thu, 01 Jan 1970"...
it's just 5 records of 3000 records it should be Thu, 01 Jan 1970 but in this 5 first lines none of them have WebMail Last Login Date on Thu, 01 Jan 1970

i need emails which have Creation Date: Wed, 14 Aug 2009 and WebMail Last Login Date: and POP3 Last Login Date : on Thu, 01 Jan 1970
# 4  
Old 03-17-2012
Try:
Code:
awk '/@/{m=$0;p=0}/Creation Date: Wed, 14 Aug 2009/{p++}/POP3 Last Login Date: Thu, 01 Jan 1970/{p++}/WebMail Last Login Date: Thu, 01 Jan 1970/{p++}p==3{print m}' file

This User Gave Thanks to bartus11 For This Post:
# 5  
Old 03-17-2012
Quote:
Originally Posted by bartus11
Try:
Code:
awk '/@/{m=$0;p=0}/Creation Date: Wed, 14 Aug 2009/{p++}/POP3 Last Login Date: Thu, 01 Jan 1970/{p++}/WebMail Last Login Date: Thu, 01 Jan 1970/{p++}p==3{print m}' file

that was great can you give a good resource or tutorial for awk. it was brilliant Smilie Smilie
# 6  
Old 03-17-2012
This one seems quite good: The AWK Manual - Table of Contents
This User Gave Thanks to bartus11 For This Post:
# 7  
Old 03-17-2012
Quote:
Originally Posted by bartus11
This one seems quite good: The AWK Manual - Table of Contents
thx man did you read that ?? i want to know more about your command is it helpful about
m=$0;p=0 or p++ and some things like this ? Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Match file and extract the output

Hi All I have 2 file . I need match the files based on key and then form a third file which have the matching values FILE1: 10264;K*AD 10265;K*AIR 10266;K*AUTO 10267;K*BABY 10268;K* FOOD FILE2: 10264;1055.83 10265;716.94 10267;331.80 10268;23283.33 OUTPUT (Needed)... (2 Replies)
Discussion started by: arunkumar_mca
2 Replies

2. UNIX for Beginners Questions & Answers

Help with pattern match and Extract

Hi All, I am having a file like below . Basically when SB comes in the text with B. I have to take the word till SB. When there only B I should take take till B. Tried for cut it by demilter but not able to build the logic SB- CD B_RESTO SB_RESTO CRYSTALS BOILERS -->There SB and B so I... (6 Replies)
Discussion started by: arunkumar_mca
6 Replies

3. Shell Programming and Scripting

Match and extract data using two files

Hello, Using the information in file 1, I would like to extract from file2 all rows which matchs in column 3. file 1 1233 1230 1231 1232 file2 65733.00 19775.00 1220 65733.00 19793.00 1220 65733.00 19801.00 1220 65733.00 19809.00 1231 65733.00 19817.00 ... (2 Replies)
Discussion started by: jiam912
2 Replies

4. Shell Programming and Scripting

How to extract next n characters after a match is found?

Hi, I want to extract the next 7 characters after I encounter the first ( in the code eg abc123=(xvn1342) xyz678123=(ret8901) I want to extract xvn1342,ret8901. Please advise how to achieve this with awk, if possible? (9 Replies)
Discussion started by: sidnow
9 Replies

5. Shell Programming and Scripting

Extract lines that match a pattern

Hi all, I got a file that contains the following content, Actually it is a part of the file content, Installing XYZ XYZA Image, API 18, revision 2 Unzipping XYZ XYZA Image, API 18, revision 2 (1%) Unzipping XYZ XYZA Image, API 18, revision 2 (96%) Unzipping XYZ XYZA Image, API 18,... (7 Replies)
Discussion started by: Kashyap
7 Replies

6. Shell Programming and Scripting

Pattern Match & Extract from a string

Hi, I have long string in 2nd field, as shown below: REF1 | CLESCLJSCSHSCSMSCSNSCSRSCUDSCUFSCU7SCV1SCWPSCXGPDBACAPA0DHDPDMESED6 REF2 | SBR4PCBFPCDRSCSCG3SCHEBSCKNSCKPSCLLSCMCZXTNPCVFPCV6P4KL0DMDSDSASEWG I have a group of fixed patterns which can occur in these long strings & only... (11 Replies)
Discussion started by: karumudi7
11 Replies

7. Shell Programming and Scripting

extract DDL - output every match to separate file

Hi, i want to extract the 'CREATE INDEX' or 'CREATE UNIQUE INDEX' statements from a ddl file and output each match to a separate file. i was looking around the net but couldnīt find anything. a possible sed-script could be: sed -n '/CREATE*INDEX*/,/COMMIT/p' filename.ddlbut i couldnīt find out... (11 Replies)
Discussion started by: CactusMoon
11 Replies

8. Shell Programming and Scripting

Extract all content that match exactly only specific word

Input: 21 templeta parent 35718 36554 . - . ID=parent_cluster_50.21.11; Name=Partial%20parent%20for%20training%20set; 21 templeta kids 35718 36554 . - . ID=_52; Parent=parent_cluster_5085.21.11; 21 templeta ... (7 Replies)
Discussion started by: patrick87
7 Replies

9. Shell Programming and Scripting

Extract data from records that match pattern

Hi Guys, I have a file as follows: a b c 1 2 3 4 pp gg gh hh 1 2 fm 3 4 g h i j k l m 1 2 3 4 d e f g h j i k l 1 2 3 f 3 4 r t y u i o p d p re 1 2 3 f 4 t y w e q w r a s p a 1 2 3 4 I am trying to extract all the 2's from each row. 2 is just an example... (6 Replies)
Discussion started by: npatwardhan
6 Replies

10. UNIX for Dummies Questions & Answers

Match and Extract

Hi, I am having 2 files which are as follows : File 1 1*001 2*002 3*003 4*004 File2 002 003 I want to match the entries in File 2 against File1.If an entry from File2 is found in File1 then I need to extract the number before "*" (a delimiter) for example...i pick up... (4 Replies)
Discussion started by: tushar_johri
4 Replies
Login or Register to Ask a Question