bash:循环procces输出并终止进程

Nik*_*ikl 4 linux bash command ubuntu-12.04 output

我需要以下方面的帮助:

我使用linux来编写发送到设备的命令.我需要向设备提交grep logcat命令,然后在生成时迭代其输出并查找特定字符串.找到此字符串后,我希望我的脚本移动到以下命令.

在伪代码中

for line in "adb shell logcat | grep TestProccess"
do 
    if "TestProccess test service stopped" in line:
       print line
       print "TestService finished \n"
       break
    else:
       print line
done
Run Code Online (Sandbox Code Playgroud)

Bar*_*mar 5

adb shell logcat | grep TestProcess | while read line
do
  echo "$line"
  if [ "$line" = "TestProces test service stopped" ]
  then echo "TestService finished"
       break
  fi
done
Run Code Online (Sandbox Code Playgroud)