I would probably do something like
$ cat testfile | grep "whatever you're looking for" | grep "^<div id=\"myclass\""
Edit: I realized that I should probably add some more information.
I used cat because it's easier when chaining commands like this, and used grep again (instead of awk) mainly because I understand grep, and know next to nothing of awk. The regexp should be the same either way.
The ^ character specifies the beginning of the line. So ^stuff would find the word "stuff" in a file if and only if it occurred at the beginning of the line. It would not find "randomstuff", for example. ^random would work, however.
Conversely, the $ character specifies the end of a line. So stuff$ would wind the word "stuff" in a file if and only if it occurred at the end of the line. It _would_ find "stuff" in "randomstuff", but would not find "random".
Hope that helps!
Last edited by rose_bud4201; 03-15-2005 at 03:50 PM.
|