13

Is there an adb command similar to "locate" or "grep" that would help me find a file on my Android device?

I'm curious about adb specifically, not a search app.

EDIT: "find" has been suggested, but on my ICS device:

hydrangea@turnsole:~$ adb shell find / -name *maps*
/system/bin/sh: find: not found

On my Gingerbread device it works, though. (Except I haven't rooted that device so it lacks permission.)

hydrangea@turnsole:~$ adb shell find / -name *maps*
find: permission denied
Hydrangea
  • 295
  • 1
  • 3
  • 8

3 Answers3

10

The find command works well in adb shell. The syntax is find /path -name file_name. For searching read only areas you will need root. If the find command is not available on your particular device, you might need to install BusyBox (search the Market.)

For example,
adb shell find / -name *maps*
will find all files that contain word "maps" across the entire file system.

Chahk
  • 19,505
  • 3
  • 56
  • 80
  • 6
    If this command spams you with /somedir/: Permission denied append 2>/dev/null to the command to mute error messages. – aleksikallio Mar 01 '12 at 12:38
  • 1
    find -> /system/bin/sh: find: not found — out of luck. How do I install find onto a borked device which manufacturer decided to not include find into firmware? – Display Name Jan 18 '16 at 07:42
  • @DisplayName did you find a way to install find ??? – zsubzwary Nov 06 '22 at 07:20
  • No I didn't. I've been through some devices dying and some OS upgrades since then. Now it comes preinstalled with the latest LineageOS builds. – Display Name Mar 05 '23 at 11:49
6

find utility come with BusyBox or another 3rd parts.

To use native capabilities try (ls -R on android, grep on PC):

adb shell ls -lR / | grep 'REGEX'
gavenkoa
  • 323
  • 5
  • 10
3

"find" is a command line application which might be normally installed as: 1. a binary executable (most desktop machines) or 2. something small doing many things where one of them is "find" or 3. might be not available as phone manufacturers don't like users to have too much control over their phones

Most likely you have one branded (ex. samsung) ICS device - manufacturers want to have more control on the device than owner does. Gain root there, then install busybox. Device is most likely something called "/system/bin/toolbox" - you could execute "/system/bin/toolbox find" but it is likely to return "no such tool" since manufacturer intentionally removed it from the device.

It is however possible that your device has the feature within its bundled toolbox - but just not "symlinked"... if "/system/bin/toolbox find" would execute the feature then you might use "ln /system/bin/find toolbox" command (I might have messed the order of params). Before executing "ln ..." you must remount device in read-write mode (either by using "adb root" or "su;mount -o remount,rw /system"