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.


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 Apr 10 '18 at 20:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.