带空格的 adb shell 输入文本

Lav*_*ham 8 shell android adb-shell

如何使用“某些文本”之类的空格发送文本adb shell input text?

找到以下解决方案

adb shell input text "some%stext"工作正常。但是有什么简单的方法可以用 %s 替换空间?

例子:

$ 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)
Run Code Online (Sandbox Code Playgroud)

小智 11

你可以这样做\<space>,像这样:

adb shell input text "some\ text"
Run Code Online (Sandbox Code Playgroud)


kai*_*-dj 6

安装了 gnu-linux sed(或其他)(大多数 linux 机器都预装了它) - 您可以使用 sed 用 %s 替换空格。

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

% 符号必须用 \ 转义。