Nick Sellen

How to escape text for adb shell input

11 Aug 2016

Just a tiny script containing one sed command to escape input suitable for use with adb shell input text command.

sed 's/\([`\(\)<>|;&\*\\~"'"'"'\$]\)/\\\1/g' <&0

Make it exectuable then move it somewhere on your path :)

Makes it possible to enter complex passwords for example. Example in combination with pass:

adb shell input text $(pass amazon | adb-escape-text)