Pipe Commands

Kae Verens kae at verens.com
Tue Sep 9 13:21:22 UTC 2008


Gopal Ghosh wrote:
> Dear All,
> my self gopal ghosh a  newbie in Linux world. found myself in love with 
> Linux as i came to know the power of Linux CLI
> 
> if two different commands are separated by || (a method by which two 
> comands can be executed one after another )
> such as
> ls || nano
> 
> the above command executes both the command with out stops after 
> executing the first one.
> 
> the book says that it will stop executing further after the first command
> but it is not the same which i observed
> pls help

'||' means 'or'. In a list of commands separated by '||', each of the commands are run until one of them succeeds.

as an example:
echo 1 || echo 2

this echoes '1' to the screen, but '2' is /not/ echoed.

in your command, 'nano' should only run if 'ls' fails.

for example, as a normal user, run this:
ls /root || nano

in that case, nano will run, but in this, it won't:
ls ~ || nano

I hope that helps!

kae




More information about the Fedora-laptop-list mailing list