Issuing adb shell commands with arguments So I can issue a shell command on my GalaxyS5 device using this:

$ adb shell run-as com.steenriver.littlecrane 'sh -c pwd'
/data/data/com.steenriver.littlecrane
$ adb shell run-as com.steenriver.littlecrane 'sh -c ls'
cache
files
lib


So far so good.

Now, if I want to supply an argument to the command, the shell will not see it:

$ adb shell run-as com.steenriver.littlecrane 'sh -c ls files'
cache
files
lib


I also tried starting a shell outright, and then type in commands in the terminal, but doing that just makes adb hang completely, and output nothing.

$ adb shell run-as com.steenriver.littlecrane 
u0_a197@kwifi:/data/data/com.steenriver.littlecrane $ ls
&lt;hangs&gt;


How can I give an adb shell command with arguments?
"-c" switch of sh command requires (and uses) a single argument which is the full shell command as a string.

This should do the trick:

adb shell run-as com.steenriver.littlecrane 'sh -c "ls files"'


In the original example, "files" is interpreted as an extra argument of the "sh" command (simply discarded when using the "-c" switch) , not of the "ls" command.