Entering an ADB shell in a specific directory on a connected device using only one line of terminal code

I am trying to find a one-line solution for entering shell using ADB on an Android device and go directly to another directory.

Try something like this

./adb shell cd /insert_dir_here

does not work.

+4
source share
3 answers

I was surprised that no one came up with this idea, but after some experiment I found a very convenient solution.

./adb shell "cd 'whatever_directory_you_want_to_cd_into' && ls"
-3
source

Following the command adb shellwith the command, it is deleted remotely and immediately returns to the host shell. therefore it ./adb shell cd /insert_dir_hereworks, but the shell immediately exits.

?

alias, :

alias myADB="cd /to/path; command1 args; command2 args; etc...."

" adb"

myADB
+1

expect decision

adb-cmd:

#!/usr/bin/env expect
spawn adb shell
expect "#"
send [ concat [ join $argv " " ] ]
send "\r"
interact

Then:

adb-cmd cd /data/
This can probably be improved by someone who knows more than Tcl than I do.

Superset: command to run adb command and stay in shell

0
source

All Articles