Filter the results of a long output to save reading

Sunday, January 10, 2010 15:57 Posted by leosaumure
You may be asked to do a command that has a long output. Reading this whole output just find one thing is tiring and if you are in an IRC or forum it is best that you do not paste unwanted data.

Many commands can be put through a secondary command before the result is outputted. Imagine search the kitchen = many results but search the kitchen and only list fruit, gives less.

This is called piping and a pipe is represented by |

So the command man conky gives the entire manual page for conky and the command lspci gives the entire list of hardware. In both cases you could pipe the command to filter the more useful information.

The command to pipe through is grep. Grep filters the results. We often need to add the switch -i to grep so that results are returned no matter what cAsE TheY ARE writtEn iN.

lspci | grep -i audio

This gives any reference to Audio audio or AUDIO in the output of the lspci command.

man conky | grep cpu

This gives only parts of the conky man page that refer to the cpu (remember grep -i will return CPU cpu Cpu cpU and so on)

Read More

0 Response to "Filter the results of a long output to save reading"

Post a Comment