I am trying to create a script to automatize a few repeated things I need to do with adb. I can run most of the commands on my local bash. But at one step, I need to find the list of some files. I then use that list in the steps that follows. What I am doing now is manually going into adb shell and copying the list:

$ adb shell

$ ls /Path/To/Folder *.abc

xyz.abc xzy.abc uvw.abc

I copy the resulting list and replace it in my script everytime before running the script.

Is it possible to run this without going into adb shell so that I could do something like this:

$ file_list="$(adb execute 'ls /Path/To/Folder *.abc')"

This way I could eliminate the repetitive manual steps and just run the script every time.

1 Answer 1


The adb interactive shell only starts if you simply run adb shell. If you add a command at the end it will be executed on the device shell and then adb returns (non-interactive mode):

adb shell ls /Path/To/Folder/*.abc

Of course in the end you can send the output to a filellist.txt on your computer:

adb shell ls /Path/To/Folder/*.abc > filelist.txt
  • Thanks for clarifying it! Now everything I need is in the script.
    – NurShomik
    Commented Apr 10, 2018 at 20:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .