0

On executing the following adb command with grep I get the following response in (darwin os) terminal. i count number of error after grep finds a "Error" string in response

adb -s derefedv645xxxxxx shell "am start -n com.samsung.networkui/.usa.EnhancedLteServices" | grep Error | wc -l

Output:

Error type 3
Error: Activity class {com.samsung.networkui/com.samsung.networkui.usa.EnhancedLteServices} does not exist.
       0

Meaning there is no "Error" text in the response. why grep is not able to capture the text "Error" ? let me know if more information is required.

siva
  • 516
  • 3
  • 7
  • 22

1 Answers1

0

You need to redirect stderr to stdout before using next comment. I would also suggest using awk to avoid 2 commands grep + wc -l:

adb -s derefedv645xxxxxx shell "am start -n com.samsung.networkui/.usa.EnhancedLteServices" 2>&1 | 
awk '/Error/ {++n} END {print n}'
anubhava
  • 761,203
  • 64
  • 569
  • 643