I have a command that outputs a stream say adb logcat
. I want to pipe that to grep until I find the first match of a certain query. At this point I want to stop the first command:
I've tried:
MY_VARIABLE=$(adb logcat | grep -m 1 'my variable (.*)')
But the problem is that the process will not stop even if grep finds the first match.
My guess is that I need to run adb logcat in nohup, pipe that command to grep, then stop it when done. But I'm not sure how to do this.