我正在尝试获取adb shell内部进程的PID。因此,我正在执行adb shell命令,以获取Android shell。现在,如果我要使用常规shell获取PID,我会使用以下命令:
我获取了PID(一个数字,在
然而,如果我在android shell中运行上述命令(在执行
adb shell ps | grep android.process.acore | sed 's/\s\s*/ /g' | cut -d ' ' -f 2
或者
adb shell ps | grep android.process.acore | awk '{ print $2 }'
我获取了PID(一个数字,在
ps | grep android.process.acore
的第二个字段中)的输出。然而,如果我在android shell中运行上述命令(在执行
adb shell
之后),我将分别得到/system/bin/sh: sed: not found
和/system/bin/sh: awk: not found
的错误。这意味着这些命令在adb shell中不可用。但是,grep可以正常工作。
adb shell
中ps | grep android.process.acore
的输出为:XXX_x21 11826 441 502296 39028 ffffffff 4010ff6c S android.process.acore
我正在寻找数字11826。如何在adb shell
中提取它?
另外,请问是否有一种直接获取adb shell中PID的方法。
谢谢, Rumit
busybox
吗? - Alex P.