Wednesday, August 12, 2009

&and& | pipe slash \

& & and &
What does & & mean and & and | and \ ?

In bash you can connect two commands together with "do this && this".

So command 1 && command 2 &

A final & on the end allows another command to run or gives you control again over the command line.

|Pipe
You can send the result of one command | into the next

e.g. ls | grep .jpg

which lists a whole directory but then pipes | the result to grep which in this case only returns .jpg

So in help it is often good to pipe the result of a long lspci command with

lspci | grep -i audio

which gets the long lspci list of pci and chooses only audio related stuff. (-i makes grep case-insensitive so that Audio AUDIO and audio are all returned)

\escape
\ will "escape" a character so where saying my book.pdf would break the command at the space you can instead say my\ book.pdf which escapes the space and has it seen as text and not a break.

Stop!
To get out of a command but leave it running do CTRL+Z

To get out of a command and stop it do CTRL+C

As these are used in the command line the conventional keyboard shortcuts of copy and paste in a terminal become SHIFT+CTRL+C and SHIFT+CTRL+V.

0 comments: