1

I have a bash script for uninstalling some software that is loaded onto our devices.

#!/bin/bash
APKS=`adb shell pm list packages projects`

for apk in $APKS
do
    apk=${apk##package:}
    echo "Uninstalling: $apk"
    adb uninstall $apk
done

When i run this script, all of the commands to uninstall an apk fail. However, when i run the exact same command (adb uninstall projects.abd.def) outside of the bash script, it executes successfully.

What am i doing wrong in the bash script?

1

1 Answer 1

1

I figured out the issue. I assumed there was a carriage return in the variable and had tested for this and it was still not working.

However, after googling a little more, i realized i was chopping off the carriage return incorrectly.

Here is the correct way:

apk=`echo -n ${apk} | tr -d "\r"`
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.