Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Piping output from 1 command to other command in an adb shell command line

I wish to send an adb shell command to an Android device that pipes output from 1 command to other command, but when I try to do that, only the 1st command is executed on the device, and the 2nd one is executed on the host machine. Here's what I tried:

adb shell command1 | command2

command1 is executed on the device, and command2 on the host machine.

How can I get this to work properly?

Thanks!

like image 939
user1118764 Avatar asked Jun 04 '13 03:06

user1118764


People also ask

How do you pipe the output of a command to another command?

The | command is called a pipe. It is used to pipe, or transfer, the standard output from the command on its left into the standard input of the command on its right. # First, echo "Hello World" will send Hello World to the standard output.

How do I run multiple commands in adb shell?

But, in order to execute several commands in one line, you may use adb shell "cmd1;cmd2;cmd3" .

What are adb shell commands?

Android Shell Commands. ADB is Android Debug Bridge which is a command line utility included with Google's Android SDK. It provides a terminal interface to control your Android device connected to a computer using a USB. ADB can be used to run shell commands, transfer files, install/uninstall apps, reboot and more.


1 Answers

You could use something like this:

adb shell "command1 | command2"
like image 123
Gabriel Porumb Avatar answered Oct 06 '22 00:10

Gabriel Porumb