Adb shell input text with space

How to send text with spaces like "some text" using adb shell input text

?

Found the following solution

adb shell input text "some%stext"

works fine. But any easy way to replace the space with% s?

Example:

$ adb shell input text "some text"
Error: Invalid arguments for command: text
Usage: input [<source>] <command> [<arg>...]

The sources are: 
      keyboard
      mouse
      joystick
      touchnavigation
      touchpad
      trackball
      dpad
      stylus
      gamepad
      touchscreen

The commands and default sources are:
      text <string> (Default: touchscreen)
      keyevent [--longpress] <key code number or name> ... (Default: keyboard)
      tap <x> <y> (Default: touchscreen)
      swipe <x1> <y1> <x2> <y2> [duration(ms)] (Default: touchscreen)
      press (Default: trackball)
      roll <dx> <dy> (Default: trackball)

      

+3


source to share


2 answers


With gnu-linux sed (or others) installed (most Linux machines come preinstalled) - you can use sed to replace spaces with% s.

adb shell input text $(echo "some text with spaces" | sed 's/ /\%s/g')

      



the% -sign character must be escaped with \.

+2


source


You can send your text like this:

Text = "some text with spaces"

      



Replace spaces% s:

adb shell input text some%stext%swith%sspaces

      

-1


source







All Articles