Need help with awk tool - finding text between two patterns
This is regarding using awk tool to find lines matching between 2 patterns.
But it's not working as expected in the following case.
[1]
If pat1 also comes after pat2 then it's matching whole file after pat1.
e.g.
Here I want only lines between first pat1 and first pat2 and want to ignore all other lines.
How to do that? Can we use sed so that this problem does not arise?
One solution that came in my mind is that change only the first pat1 by say PAT1 and then use awk '/PAT1/,/pat2/', but I am sure there are better solutions.
Last edited by Franklin52; 12-16-2009 at 04:32 AM..
Reason: Please use code tags!
Hi all experts,
here is a problem which i would appreciate ur expertise.
I need to do this:
Eg.
Find a number: 1234567 which i dunno which file and which folder
I do know which main folder it is in but it is hidden deep within a lot of subdir.
Is it possible to find the file? + output... (4 Replies)
hi, i am a c++ programmer working on linux(redhat linux8.0) environment, i need to find out the memory leaks, so far i didn't used any tools, so what are the tools are available, and whic one is good to use. plz provide with a small example. (1 Reply)
Dear Colleagues:
I have .rtf files of a collection of newspaper articles. Each newspaper article starts with a variation of the phrase "Document * of 20" and is separated from the next article with the character string "==================="
I would like to be able to take the text composing... (3 Replies)
I have a list of urls for example:
Google
Google Base
Yahoo!
Yahoo!
Yahoo! Video - It's On
Google
The problem is that Google and Google are duplicates as are Yahoo! and Yahoo!.
I'm needing to find these conical www duplicates and append the text "DUP#" in from of both Google and... (3 Replies)
Hi,
nevermind. I think I've found the answer. It appears I was looking for index, match, sub, and gsub.
I want to write a shell script that will clean the html out of a bunch of files and format the data for import into excel.
Awk seems like a powerful tool, but it seems oriented to... (1 Reply)
Hi,
I have a file with 3 columns and I want to find when the average number of rows on column 3 is a certain value. The output will be put into another file indicating the range.
Here is what I mean (file is tab separated):
hhm1 2 0
hhm1 4 0.5
hhm1 6 0.3
hhm1 8 -1.4... (2 Replies)
I an trying to parse a file looking for pattern1, or pattern2, or pattern3 and when found print that line and the next 4 lines after it. I am using korn shell script on AIX and grep -A isn't available. (1 Reply)
I would like to replace ], with ]]], between /* SECTION2-BEGIN */ and /* SECTION2-END */ in my file. My file contains the following information:
/* SECTION1-BEGIN */
,
/* SECTION1-END */
/* SECTION2-BEGIN */
,
/* SECTION2-END */
/*... (5 Replies)
Hi All,
I need help as i am not able to create shell script for a scenario.
i have 3000 numbers and want to search all the files which contain anyone of the above pattern.
the files are in folder structure.
Thanks and Regards
Rishi Dhawan (14 Replies)
Hi,
I have requirement to find the matching patterns of two files in Unix. One file is the log file and the other is the error list file. If any pattern in the log file matches the list of errors in the error list file, then I would need to find the counts of the match.
For example,
... (5 Replies)