简体   繁体   中英

grep command not found in adb shell

After my phone is connected to the computer through adb, going to adb shell and then typing grep gives me

grep: not found  

Is this a problem with my adb installation or my phone? How do I get grep to work for my device?

PS: This is the reason why I think it might a problem with my phone (as opposed to the adb installation)
https://stackoverflow.com/a/12143669/1693203
The answer says

The grep utility may not be installed on your device.

However, I may have misunderstood the statement. How do I get grep working?

grep command is not installed on your device by default. If you need to use grep command in your device, you can cross-compile busybox then invoke grep under busybox .

However if you are in Linux or Cygwin , you can pipe the command output and use the grep in PC to get result you want, eg

$ adb shell ps |grep google
app_5     279   71    200212 30928 ffffffff 00000000 S com.google.process.gapps
app_66    481   71    122804 21632 ffffffff 00000000 S com.google.android.apps.maps
app_66    32311 71    120200 20916 ffffffff 00000000 S com.google.android.apps.maps:NetworkLocationService

in your case that means:The grep utility may is not be installed on your device.

install busybox from playstore then perform

busybox grep

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