From: Matthew Lincoln on
I am not sure about on how to specify that a second command should only be execute in case
that the first command fails/succeeds.

When I enter:

cmd1 | gzip -f ... && cmd2

Is then cmd2 executed only if cmd1 is finished successfully or if gzip is finished successfully?

Is the command concatenation "&&" correct at all?

What if I want cmd2 only to execute if both (cmd1 and gzip) end successfully?

What about the other way: cmd2 should only be executed if

a) cmd1 failed

b) cmd1 or gzip failed?

Matthew
From: Bill Marcum on
On 2008-06-17, Matthew Lincoln <kmlincoln100(a)hotmail.com> wrote:
>
>
> I am not sure about on how to specify that a second command should
> only be execute in case that the first command fails/succeeds.
>
> When I enter:
>
> cmd1 | gzip -f ... && cmd2
>
> Is then cmd2 executed only if cmd1 is finished successfully or if gzip
> is finished successfully?
>
> Is the command concatenation "&&" correct at all?
>
> What if I want cmd2 only to execute if both (cmd1 and gzip) end
> successfully?
>
> What about the other way: cmd2 should only be executed if
>
> a) cmd1 failed
>
> b) cmd1 or gzip failed?
>
> Matthew

Use bash and test the PIPESTATUS array.

From: Guillaume Dargaud on
Or test the value of $?
--
Guillaume Dargaud
http://www.gdargaud.net/