Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use 2 patterm matches

Status
Not open for further replies.

fidge

Technical User
Jun 11, 2003
20
0
0
GB
Hi all,
Can anyone help with my problem?

I have a script where I need to find
a) pattern1 in file x
b) get next line details
c) If substr != PMS_GEN then
d) if substr = PMS_DEL or substr = PMS_ADD printf

Here's what I have so far which works fine:

awk '/PATTERN1/ {
if ( $7 ~ "failed," )
{ search=$0
getline
array_get[1]=$0
search=search $0
if ( substr(array_get[1],1,17) !~ " PMS_GEN" )
if ( substr(search,35,41) ~ "PMS_DEL" )
{ printf substr(search,69,11) ": " substr(array_ge[1],11) "\n" }
else if ( substr(search,35,41) ~ "PMS_ADD" )
{ printf substr(search,66,11) ": " substr(array_get[1],11) "\n" }
}

The problem I have is that I now need to get a substr of "search", and find out which file in a specified path its found in. Everything I've tried so far fails.

Thanks in advance for any help.
 

I don't understand what you want. Maybe it would help if you post some sample input and output files.

CaKiwi

"I love mankind, it's people I can't stand" - Linus Van Pelt
 
The output of search is....
"01234567890: Action not allowed"

I need to extract the 1st eleven chars (01234567890), and find out which filename its located in. Once found I need
to print the filename at the beginning of the other
printf statements in the script

i.e filename.ext - 01234567890: Action not allowed

Hope thats clearer.
Thanks.
 
What files do you want to search? *.ext in the current directory? Or are the names of the files in your input somewhere?

CaKiwi

"I love mankind, it's people I can't stand" - Linus Van Pelt
 
Thanks for trying to help with this. The good news is I have got it working, by going about it a different way

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top