Maybe you could try something like the following:
tshark OPTIONS 2>&1 | grep --line-buffered PATTERN | while read line; do
# actions for when the pattern is found, the matched input is in $line
break
done
The 2>&1
is important so that when PATTERN is matched and the while loop terminates, tshark
has nowhere to write to and terminates because of the broken pipe.
If you want to keep tshark
running and analyze future output, just remove the break
. This way, the while loop never terminates and it keeps reading the filtered output from tshark
.