Pipe output through a bash or, double pipe, || expression? -


i have noisy command output want hide on success. however, in failure case, output might prove helpful debugging, want show before printing error message.

currently, way:

output=$( cmd1 2>&1 ) || {   echo $output   echo cmd1 failed   exit 1 } 

is possible pipe cmd1's output through || (or, double-pipe) can avoid creating variable output?

you need save output of command somewhere because don't know until command finishes whether or not send output console. piping output won't help, since pipes don't have large buffers.

you have few options buffering, using variable reasonable 1 if don't expect megabytes of output, go beyond definition of noisy. use temporary file, there few advantages unless you're intending deploy on system limited memory (by today's standards).


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -