Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

what does "¦¦" in unix does?

Status
Not open for further replies.

slok

Programmer
Jul 2, 1999
108
SG
what's the purpose of || when used with other commands?
 

It basically does the OR operation
it takes the o/p of commands and perform OR operation..
 

Try this:

# test -e foo.bar || echo $?

If the file foo.bar is not in the working directory then an exit code of 1 will
be provided by the " or " to echo exit status.

 
One of the things to keep in mind is that while a single pipe (|) is a logical OR that evaluates all arguments, the double pipe (the one you refer to) will exit processing as soon as it receives a true value.

Hope this helps,

brendanc@icehouse.net
 
To expand upon what marsd said, if the first command terminates with an exit code other than 0, it is considered to have failed. In this case, the second command is executed.

If the first command terminates with a 0, it is perceived to be a success and the second command is ignored.

On a similar note is the and (&&) feature. With and, the second command is executed only if the first command terminates successfully (i.e., exit code 0).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top