![]() |
|
|
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 |
| search a pattern and if pattern found insert new pattern at the begining | pitagi | Shell Programming and Scripting | 7 | 02-12-2009 10:27 PM |
| modify a particular pattern starting from second line of the search pattern | imas | UNIX for Dummies Questions & Answers | 1 | 10-12-2008 02:19 PM |
| modify a particular pattern starting from second line of the search pattern | imas | UNIX for Dummies Questions & Answers | 2 | 10-12-2008 12:30 PM |
| Check whether the pattern is present or not? | skyineyes | Shell Programming and Scripting | 8 | 06-27-2007 10:42 AM |
| Search file for pattern and grab some lines before pattern | frustrated1 | Shell Programming and Scripting | 2 | 12-22-2005 03:41 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
search pattern present in second field
Hi All, I have a file with following list. example 1 ======== cat 1.txt -------- Code:
0000cab4752c 0000dab47c2c ... ... ... Also i have another file 2.txt in which the data is in this format as shown: cat 2.txt --------- Code:
4591dc00fffffc0001002369774394|4591dde101002369774394|6.14.221.2|1250753484144|5|360|1250751684144|1250753034144|1110767654|false|1249217618553|1250749884144|1250755284144|1250755284144|false|0000cab47c2c|Scope6914522|01040004000602060000cab47c2c ... ... Now i wrote script to take each pattern from 1.txt and grep in 2.txt and if the result matches then redirect to 3.txt Code:
for i in `cat 1.txt` do grep "$i" 2.txt >>3.txt done But my requirement is to grep for a given pattern which should be present in the second field of the 2.txt then only print it. example 2 ----------- 1.txt ------ Code:
0000cab47c2c 2.txt ----- Code:
4591dc00fffffc0001002369774394|4591dde---0000cab47c2c---- |6.14.221.2|1250753484144|5|360|1250751684144|1250753034144|1110767654|false|1249217618553|1250749884144|1250755284144|1250755284144|false|0000cab47c2c|Scope6914522|01040004000602060000cab47c2c If you notice i placed a hypen --- at the start and end of the pattern to be searched. I want this kind of result but not the one which is shown in my first example. Your help is much appreciated. Thanks imas Last edited by Franklin52; 08-20-2009 at 05:35 AM.. Reason: Please use code tags! |
|
||||
|
Hi Panyam,
Thank you, Thank you, Thank you very much. Yes, finally i got the expected output. But, Please please please do let me know which books i refer from beginner, intermediate and advance level in scripting so that i can be more independent and help dumb ppl like me who are trying to convey that unix is more user friendly, fastest and reliable O/S. Please do post your reply. Iam eagerly waiting for your reply. Thanks -imas |
|
||||
|
imas, Hope if you google you will get more and more links and resources. I really don't have any idea on the best books , but for awk/sed these links are useful. Code:
www.grymoire.com/Unix/Awk.html www.grymoire.com/Unix/Sed.html |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|