Nick Sellen

How to escape text for adb shell input

11 August 2016

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

#!/bin/sh
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)

I don't have comments enabled here, but you are welcome to contact me directly. View the homepage for different ways to do that.