简体   繁体   中英

if condition on adb logcat doesn't work

I am trying the following code to get if condition on adb logcat:-

Search for the Exception or ANR (Activity Not Responding) on com.testapp.demo package If any Exception or ANR is found it will save the logs into the destination folder

if adb logcat | grep 'Exception*'
then
    adb logcat -d > $SILENT_EXCEPTION_FILE
fi

but I am not able to save it. Somehow this command does not work.

adb logcat outputs the logs as they arrive and never exits, so adb logcat | grep adb logcat | grep never exits either. adb logcat -d should be used if you want to read the current logs.

我建议使用以下内容:

adb logcat | grep --line-buffered 'Exception*' > $SILENT_EXCEPTION_FILE

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM