如何列出所有的文件在 android 手机使用 adb 外壳?

我只是尝试为我的 Android 手机编写一个 bash shell。
当我想列出所有的文件在我的 Android 手机。我发现 Android shell 终端不支持 find命令。
所以我只是想知道哪种方式是最好的旅行 sdcard文件?

263367 次浏览

I might be wrong but "find -name __" works fine for me. (Maybe it's just my phone.) If you just want to list all files, you can try

adb shell ls -R /

You probably need the root permission though.

Edit: As other answers suggest, use ls with grep like this:

adb shell ls -Ral yourDirectory | grep -i yourString

eg.

adb shell ls -Ral / | grep -i myfile

-i is for ignore-case. and / is the root directory.

Open cmd type adb shell then press enter. Type ls to view files list.

just to add the full command:

adb shell ls -R | grep filename

this is actually a pretty fast lookup on Android

This command will show also if the file is hidden adb shell ls -laR | grep filename

Some Android phones contain Busybox. Was hard to find.

To see if busybox was around:

ls -lR / | grep busybox

If you know it's around. You need some read/write space. Try you flash drive, /sdcard

cd /sdcard
ls -lR / >lsoutput.txt

upload to your computer. Upload the file. Get some text editor. Search for busybox. Will see what directory the file was found in.

busybox find /sdcard -iname 'python*'

to make busybox easier to access, you could:

cd /sdcard
ln -s /where/ever/busybox/is  busybox
/sdcard/busybox find /sdcard -iname 'python*'

Or any other place you want. R