|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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 { } |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
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? |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
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. |
|
![]() |
| Outils de la discussion | |
|
|