friddle
friddle

Reputation: 1347

How to list all the files in android phone by using adb shell?

I just try to write a bash shell for my Android Phone.
When I want list all the files in my Android Phone. I found that the Android shell terminal doesn't support find command.
So I just want to know which is the best way to travel the sdcard files?

Upvotes: 120

Views: 336781

Answers (6)

Alex Rudnicky
Alex Rudnicky

Reputation: 296

I'm working with

Android Debug Bridge version 1.0.41
Version 34.0.5-10900879

In powershell on Win 10, connecting to Pixel 7 / Android 14. You now have to quote the shell input when piping:

adb shell 'ls storage/emulated/0/ | wc'

Upvotes: 0

historystamp
historystamp

Reputation: 1478

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

Upvotes: 2

pt2121
pt2121

Reputation: 11880

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.

Upvotes: 171

Misha
Misha

Reputation: 443

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

Upvotes: 3

rngd
rngd

Reputation: 51

just to add the full command:

adb shell ls -R | grep filename

this is actually a pretty fast lookup on Android

Upvotes: 4

fauzi
fauzi

Reputation: 347

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

Upvotes: 33

Related Questions