The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 04-23-2009
lavascript lavascript is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 47
Thanks dude thats worked like a charm.

Seems i was almost there but didn't use the correct { }

Could you explain the difference between { } and ( ) in the command grouping? Also i notied the ; at the end before } is vitally important otherwise the next command doesn't work.

e.g


Code:
This works and exits if cant null but echos got to here if can.

> ${OUTFILE} || { print "ERROR: cannot null output file. Exiting\n" >&2; exit 2; }
> ${TMPFILE} || { print "ERROR: cannot null tmp file. Exiting\n" >&2; exit 2; }

echo "got to here"

This doesnt work and never gets to echo even if null is successful

> ${OUTFILE} || { print "ERROR: cannot null output file. Exiting\n" >&2; exit 2 }
> ${TMPFILE} || { print "ERROR: cannot null tmp file. Exiting\n" >&2; exit 2 }

echo "got to here"