How to pass commands to ADB shell? 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=&quot;$(adb execute 'ls /Path/To/Folder *.abc')&quot;

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 &gt; filelist.txt