I want to zip the sql dump if and only if mysqldump does not produce any error. I try to put the wrong password, but it still perform the gzip. mysqldump -u username -ppassword dbname |& if [ $? == 0 ]; then gzip > test.gz; else echo error; fiWhat is wrong with my command or is there any better solution?
How to gzip only if mysqldump does not error?
shell script;pipe;return status