Reputation: 65
I want to grep a string to adb logcat and if it matches it should go inside if statement else exit.THe following code doesnot work
if[ ./adb logcat | grep --line-buffered 'Monkey aborted due to error.' ]; then
adb logcat -d > MONKEY_WORKING_DIR/logcat_MonkeyWithoutPackageName.txt
fi
Upvotes: 0
Views: 764
Reputation: 782407
You only use [
if you want to test the value of an expression, not if you want to test whether a command is successful. If you're testing a command line, you just put that command after if
.
if ./adb logcat | grep --line-buffered 'Monkey aborted due to error.'
then
...
fi
Also, you need to have a space between if
and [
.
Upvotes: 3