Shell Script, Search File for String
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 impleme开发者_StackOverflownt this using grep, awk, or sed?
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"
精彩评论