How to search 2 separate patterns from a 2nd file.?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to search 2 separate patterns from a 2nd file.?
# 1  
Old 05-29-2014
How to search 2 separate patterns from a 2nd file.?

Hi Guys,

Need your urgent support please. I have a file with 3 separate strings separated by a comma and 2nd file which has a sentence where I can find these 3 strings. I need to find sentences which do not have these strings and maybe redirect it to a 3rd file.

All the 3 strings will occur in a single string and may contain 3 or more characters between them.

1st file
Code:
22220107328,internet3g.chinguitel.mr,20140510132035
447412516941,three.co.uk,20140510133306
34626666739,blackberry.net,20140510133634
94778021241,ppwap,20140510134013
32471334936,SARENS.BE,20140510134126
353864602784,wyless.net,20140510134218
6282194426999,INTERNET,20140510134420
201006078195,BLACKBERRY.NET,20140510135155
3197002170846,RITESIM.M2M,20140510135244
4541161470,INTERNET,20140510135337

2nd file
Code:
0000010514EB01497430195MTC923210006020        00923357532489          2014051101242600000000            E202AO  1                        4100361137565520021
 353278053594710 PAKUF           282632826302013020130000000000000                  M217           011933971                             966540144007
                                   00
0000020514EB01497430195MTC12642359605         00905339574666          2014051101243000000000            N215O   1                        2860150330746660021
 351553053260940 TURTC           595115951102156021560000000000000                  M217           011934131                             966540144007
                                   00

Hope I have been able to explain it clearly.

Last edited by Scrutinizer; 05-29-2014 at 05:11 AM.. Reason: QUOTE tags change to CODE tags
# 2  
Old 05-29-2014
Could you specify the expected output? I can't see any of the pattern from file1 into file2 !
# 3  
Old 05-29-2014
Quote:
Originally Posted by danish0909
I need to find sentences which do not have these strings and maybe redirect it to a 3rd file.
Do you want lines with none of the strings, or lines which are missing one or more?

e.g. given
Code:
eat,more,pie

and
Code:
I like to eat pie
I always want to eat some more pie
I'm dieting

is your expected output
Code:
I'm dieting

or
Code:
I like to eat pie
I'm dieting

# 4  
Old 05-29-2014
Thanks for replying..

if you see below is an example of a record which is available
Quote:
cat records_gprs.txt|grep 22220107328|grep 20140510132035
0000040514BB00677630456ORD22220107328 internet3g.chinguitel.mr20140510132035000432001M2P5 60902020170723900 3583040583121301 38842 020130 SGSN 4113576291 012110.10.230.141 1720140510132035172969927800000000000000000000004190880022068584.23.98.145 41.138.142.129 0
For the same I have taken the 1st column and 3rd column from the 1st file and grepped it from the 2nd file.

Similarly, the 2nd file also has the below record which does not match the pattern specified above and I want an output like the below

Quote:
0000030514G801813330456ORD221774118906 INTERNET 20140511010726000009671 60801510162556900 0120320092604103SEN
AZ 34213 036070 SGSN 10606334350036012110.148.89.204 0020140511010726028767560600000000000000000000000165420001119784.23
.99.2 196.207.250.2 0

Let me know if you need any more information

Last edited by danish0909; 05-29-2014 at 09:44 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk search patterns from file in another

I would like to grep for aaa and bbb and ccc from one line in file1.txt in any order on a line on file2.txt file1.txt aaa bbb ccc ddd fff ggg hhh ddd jjj jjj cccfile2.txt aaa bbb ccc ddd fff ggg --> output whole line since it matches with aaa bbb ccc of file1.txt aaa ddd jjj hhh --> no... (1 Reply)
Discussion started by: sdf
1 Replies

2. Shell Programming and Scripting

How to search multiple patterns and remove lines from a file?

Hi, I have a file content as below. Table : PAYR Displayed fields: 15 of 15 Fixed columns: 4 List width 0999... (4 Replies)
Discussion started by: shirdi
4 Replies

3. UNIX for Dummies Questions & Answers

Search a file for patterns from another file to another with awk

Hi all ! I have 2 files: file1: 1|AAA|123456 2|BBB|098765432 ... file2: -|klk|AAA|$123.00|Qty.2|US -|opi|EEE|$23.00|Qty.4|US ... Output: 1|AAA|-|klk|AAA|$123.00|Qty.2|US I would need to search the 3rd field of file2 for the patterns contained in the 2nd field of file1. And... (10 Replies)
Discussion started by: beca123456
10 Replies

4. Shell Programming and Scripting

reading lines from a file between two search patterns

Hi, I am new to shell scripting and is working on a script to extract lines from a log file between two time stamps using awk command. After some research I used following command: awk '/01 Oct 2011/{p=1} /10 Oct 2011/{p=0} p' test.log >> tmp.log This works fine. But now i want to... (3 Replies)
Discussion started by: davidtd
3 Replies

5. Shell Programming and Scripting

to read two files, search for patterns and store the output in third file

hello i have two files temp.txt and temp_unique.text the second file consists the unique fields from the temp.txt file the strings stored are in the following form 4,4 17,12 15,65 4,4 14,41 15,65 65,89 1254,1298i'm able to run the following script to get the total count of a... (3 Replies)
Discussion started by: vaibhavkorde
3 Replies

6. Shell Programming and Scripting

Need help in retrieving log from a UNIX file using the search patterns

Hi everyone, I am trying to retrieve certain log from a big file. The log size can be from 200 - 600 lines. I have 3 search patterns, out of which 2 (first and last lines) search patterns are common for all the transactions but 3rd search pattern (occurs in the middle of transaction) is... (5 Replies)
Discussion started by: msrayudu
5 Replies

7. Shell Programming and Scripting

Search through subfolders and move them into separate folder on the base of file size

Hello guys I am sure that you will help me on this issue as you did earlier::) Scenario : I have a folder named "XYZ". It consist many sub-folders and subfolder contain severals files. there may be abc.dat in each subfolder. Now i want to seperate subfolders on follwing conditions- if abc.dat... (12 Replies)
Discussion started by: infiant
12 Replies

8. Shell Programming and Scripting

Searching patterns in 1 file and deleting all lines with those patterns in 2nd file

Hi Gurus, I have a file say for ex. file1 which has 3500 lines in it which are different account numbers and another file (file2) which has 230000 lines in it. I want to read all the lines in file1 and delete all those lines from file2 which has that same pattern as in file1. I am not quite... (4 Replies)
Discussion started by: toms
4 Replies

9. Shell Programming and Scripting

Perl - How to search a text file with multiple patterns?

Good day, great gurus, I'm new to Perl, and programming in general. I'm trying to retrieve a column of data from my text file which spans a non-specific number of lines. So I did a regexp that will pick out the columns. However,my pattern would vary. I tried using a foreach loop unsuccessfully.... (2 Replies)
Discussion started by: Sp3ck
2 Replies

10. UNIX for Dummies Questions & Answers

How to parameterize multiple search patterns and generate a new file

I have one file: 123*100*abcd*10 123*101*abcd*-29*def 123*100*abcd*-10 123*102*abcd*-105*asd I would like to parameterize the search patterns in the following way so that the user could dynamically change the search pattern. *100* and *- (ie *minus) *102* and *- The output that is... (6 Replies)
Discussion started by: augustinep
6 Replies
Login or Register to Ask a Question