Advertisement

08.19.2007 at 01:46AM PDT, ID: 22772396
[x]
Attachment Details

bash. success or exit

Asked by dportabella in Bourne-Again Shell (bash)

Tags: bash, exit, success

In a bash script,
I need that if a command fails, the script exits.

Now I do as follows:
++++++++
cat example.txt
if [ $? -ne 0 ]; then exit; fi;
++++++++

is there a more compact way of doing this?
something like
cat example.txt  __SUCCESS_OR_DIE__

Start Free Trial
[+][-]08.19.2007 at 01:47AM PDT, ID: 19725122

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Bourne-Again Shell (bash)
Tags: bash, exit, success
Sign Up Now!
Solution Provided By: ahoffmann
Participating Experts: 2
Solution Grade: A
 
 
[+][-]08.19.2007 at 01:55AM PDT, ID: 19725136

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.19.2007 at 03:37AM PDT, ID: 19725298

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628