This question already has an answer here:

I have solaris machine ( solaris 10 )

please Look on the following simple commands (haconf -makerw | grep -iq "Cluster already writable")

    # haconf -makerw 
      VCS WARNING V-16-1-10364 Cluster already writable.

    haconf -makerw | grep -iq "Cluster already writable"
    # echo $?

I get exit status 0 from grep ,

and this is right ( because we get the exe status always the last command )


my question is:

how to get the exit status ( $? ) from the command haconf -makerw in place of grep?

or what need to add in to my syntax in order to understand if haconf -makerw succeeded ?

    haconf -makerw | grep -iq "Cluster already writable"
    # echo $? ( will print the exe status from haconf -makerw  )

merged by Michael Mrozek May 17 '13 at 14:34

This question was merged with Get exit status of process that's piped to another because it is an exact duplicate of that question.