views:

94

answers:

1

I'm writing a shell script that opens a file and needs to find a tag like ##FIND_ME##. The string I'm searching for is a constant (and there is only ever one instance of it.)

Once I locate that string, I need it to start a new search for a different string from that point forward.

My *nix skills are a little rusty, should try to implement this using grep, awk, or sed?

+2  A: 
awk '/FINDME/{f=1}f&&/NEWSEARCH/{print}' file

shell

f=0
while read -r line
do
 case "$line" in
   *FINDME* ) f=1;;
 esac
 if [ "$f" -eq 1 ] ;then
    case "$line" in
      *NEWSEARCH*) echo "found next tag in: $line";;
    esac
 fi
done <"file"
ghostdog74
This is exactly what I was looking for, thanks for your help.
pws5068