Linux: How to search and print command output?

Well today, I was trying to do a simple test with Ubuntu. .. that is trying to print the output of the ‘ps -aux‘ command. It wasn’t that bad. The way to do this is to pipe it into the ‘LPR’ that is your printer.

e.g. ps -aux | lpr

This will send the output to your printer for printing. Not hard at all. :-)

For searching, you can use the same piping trick but with the ‘grep’ command after it.

e.g. ps -aux | grep testing

This will search the output for the word testing and listed them out.

To get fancy, you can then send the output of the search results to your printer.

ps -aux | grep testing | lpr

That’s the beauty of Linux. Piping in Linux is very useful.