|
From: Matthew Lincoln on 17 Jun 2008 02:16 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 17 Jun 2008 03:18 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 18 Jun 2008 08:58 Or test the value of $? -- Guillaume Dargaud http://www.gdargaud.net/
|
Pages: 1 Prev: How to display "7" as left "0" padded 4 char wide field: "0007" ? Next: un-closed files |