Running shell script in Android adb shell

后端 未结 2 656
闹比i
闹比i 2021-01-21 17:56

I\'m trying to create a script to find and remove my app from the Android emulator through the adb shell.

This is what I\'ve got:

adb shell \"
cd data/ap         


        
相关标签:
2条回答
  • 2021-01-21 18:15

    I'm still curious to know why my approach was "suboptimal" and what could I have done better?

    Wild guess since I'm not familiar with adb shell but bash: Quotation. Variables can not be inside ticks '...$VAR' but "...$VAR". Anything inside ticks is taken "as is", i.e. literally:

    echo 'bundle name is $bundle'
    

    vs.

    echo "bundle name is $bundle"
    
    0 讨论(0)
  • 2021-01-21 18:32

    You should not really go through the /data/app folder. If you want to uninstall multiple packages with names matching the com.mycompany pattern with a single adb command use:

    adb shell "pm list packages com.mycompany | cut -c9- | xargs -n 1 sh /system/bin/pm uninstall"
    
    0 讨论(0)
提交回复
热议问题