Question 3.29: You want to use the output of one Linux command as the input......

You want to use the output of one Linux command as the input to another command.

Step-by-Step
The 'Blue Check Mark' means that this solution was answered by an expert.
Learn more on how do we answer questions.

Use the pipe command, which is the bar symbol (|) on your keyboard, to pipe the output of one command to another. For example:

$ ls -l *.py | grep Jun
-rw-r–r– 1 pi pi 226 Jun 7 06:49 speed.py

This example will find all the files with the extension py that also have Jun in their directory listing, indicating that they were last modified in June.

Discussion

At first sight, this looks rather like output redirection using > (Recipe 3.27). The difference is that +>_ will not work where the target is another program. It will only work for redirecting to a file.

You can chain together as many programs as you like, as shown here, although this isn’t something you will do often:

$ command1 | command2 | command3

See Also

See also Recipe 3.24 for an example of using grep to find a process, and Recipe 3.23 to search your command history using a pipe and grep.

Related Answered Questions

Question: 3.34

Verified Answer:

Use the Linux df command: $ df -h Filesystem   ...
Question: 3.33

Verified Answer:

Use the Linux date command. The date and time form...
Question: 3.32

Verified Answer:

Edit the file ~/.bashrc using nano (Recipe 3.6), a...
Question: 3.31

Verified Answer:

Run the program or command in the background using...
Question: 3.30

Verified Answer:

Redirect the output to /dev/null using >. For e...
Question: 3.24

Verified Answer:

Use the Task Manager utility, which you’ll find on...
Question: 3.27

Verified Answer:

Use the > command to redirect output that would...
Question: 3.28

Verified Answer:

Use the cat command to concatenate a number of fil...
Question: 3.26

Verified Answer:

Use the lsusb command. This will list all the devi...
Question: 3.25

Verified Answer:

Depending on the file type, you will need to use t...