bash 在 adb shell 中找不到 grep 命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27615220/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
grep command not found in adb shell
提问by user13267
After my phone is connected to the computer through adb, going to adb shell and then typing grep
gives me
我的手机通过adb连接电脑后,进入adb shell然后打字grep
给我
grep: not found
Is this a problem with my adb installation or my phone? How do I get grep to work for my device?
这是我的 adb 安装问题还是我的手机问题?如何让 grep 为我的设备工作?
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
PS:这就是为什么我认为它可能是我的手机有问题的原因(与 adb 安装相反)
https://stackoverflow.com/a/12143669/1693203
答案说
The grep utility may not be installed on your device.
您的设备上可能未安装 grep 实用程序。
However, I may have misunderstood the statement. How do I get grep working?
但是,我可能误解了该声明。我如何让 grep 工作?
回答by alijandro
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
.
grep
默认情况下,您的设备上未安装命令。如果您需要grep
在您的设备中使用命令,您可以交叉编译busybox
然后grep
在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, e.g.
但是,如果您在Linux
或 中Cygwin
,则可以通过管道grep
传输命令输出并使用in PC 来获得您想要的结果,例如
$ 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