PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > How to match two key words in a paragraph
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

How to match two key words in a paragraph

Réponse
 
LinkBack Outils de la discussion
Vieux 20/04/2008, 01h39   #1
webinfinite@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut How to match two key words in a paragraph

Hi,

I have a document in which I like to look for key words: wordA and
wordB. I need to first find where wordA is located in the paragraph
and from this position, I need to find wordB's value. For example,

Hello, World
This {

}
  Réponse avec citation
Vieux 20/04/2008, 01h45   #2
webinfinite@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to match two key words in a paragraph

Sorry, I didn't finish in the above thread. Let me reinstate:

I have a document in which I like to look for key words: wordA and
wordB. I need to first find where wordA is located in the paragraph
and from this position, I need to find wordB's value. For example,

Hello, World
This {
value = "ABC"
}
That {
value = "DEF"
}

I need to first find out "That". At this point, I don't need anything
above "That". Then I need to find out in the paragraph under where
"That" is located if the value equals "DEF".

Could anybody tell me how I can find out two words in paragraph? nawk
can be used for keywords in a single line but here I need to do a
similar task in a paragraph. Any suggestion?
  Réponse avec citation
Vieux 20/04/2008, 02h05   #3
Ed Morton
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to match two key words in a paragraph



On 4/19/2008 7:45 PM, webinfinite@gmail.com wrote:
> Sorry, I didn't finish in the above thread. Let me reinstate:
>
> I have a document in which I like to look for key words: wordA and
> wordB. I need to first find where wordA is located in the paragraph
> and from this position, I need to find wordB's value. For example,
>
> Hello, World
> This {
> value = "ABC"
> }
> That {
> value = "DEF"
> }
>
> I need to first find out "That". At this point, I don't need anything
> above "That". Then I need to find out in the paragraph under where
> "That" is located if the value equals "DEF".
>
> Could anybody tell me how I can find out two words in paragraph? nawk
> can be used for keywords in a single line but here I need to do a
> similar task in a paragraph. Any suggestion?


It's easily done in awk. Exactly how depends on more details about your input
file, but one way given the file you show above would be:

awk -v RS="}" '$1=="That" && $5=="\"DEF\""{ print "found" }' file

If that doesn't work on your real input file, provide a more truly
representative sample input, expected output from that input, and description of
how to find the fields you're interested in.

Regards,

Ed.

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 09h01.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,09934 seconds with 11 queries