What is the purpose of the || in unix commands

What is the purpose of the || in unix commands

am 05.10.2007 08:06:08 von parag_paul

x_RH3_AMD64_VCS2008.03_32_debug_Engineer/lib -lBA /remote/vtgimages/
SAFE/linux_RH3_AMD64_VCS2008.03_32_debug_Engineer/vhdl-src/s nps/
synopsys/linux/lib/ctype-stubs_32.a -lncurses -ldl || rm -f simv
simv up to date

Re: What is the purpose of the || in unix commands

am 05.10.2007 08:45:09 von Barry Margolin

In article <1191564368.514201.142240@22g2000hsm.googlegroups.com>,
"parag_paul@hotmail.com" wrote:

> x_RH3_AMD64_VCS2008.03_32_debug_Engineer/lib -lBA /remote/vtgimages/
> SAFE/linux_RH3_AMD64_VCS2008.03_32_debug_Engineer/vhdl-src/s nps/
> synopsys/linux/lib/ctype-stubs_32.a -lncurses -ldl || rm -f simv
> simv up to date

It's the logical, short-cutting "or" operator, similar to C and perl.
If the command before || has a non-zero exit status, indicating failure,
the next command is executed.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***

Re: What is the purpose of the || in unix commands

am 05.10.2007 08:53:32 von cfajohnson

On 2007-10-05, parag_paul@hotmail.com wrote:
> x_RH3_AMD64_VCS2008.03_32_debug_Engineer/lib -lBA /remote/vtgimages/
> SAFE/linux_RH3_AMD64_VCS2008.03_32_debug_Engineer/vhdl-src/s nps/
> synopsys/linux/lib/ctype-stubs_32.a -lncurses -ldl || rm -f simv
> simv up to date

From the bash man page:

command1 || command2

command2 is executed if and only if command1 returns a non-zero exit
status.


--
Chris F.A. Johnson, author
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence

Re: What is the purpose of the || in unix commands

am 05.10.2007 16:37:30 von Bill Marcum

On 2007-10-05, parag_paul@hotmail.com wrote:
> x_RH3_AMD64_VCS2008.03_32_debug_Engineer/lib -lBA /remote/vtgimages/
> SAFE/linux_RH3_AMD64_VCS2008.03_32_debug_Engineer/vhdl-src/s nps/
> synopsys/linux/lib/ctype-stubs_32.a -lncurses -ldl || rm -f simv
> simv up to date
>
man sh
The command on the right side of || is executed if the command on the
left returns nonzero status.