samedi 2 septembre 2017

Shell - run bunch of commands in IF else

I would like to prepare a shell script, that will execute my all commands if my all commands went success then it'll print "SUCCESS" and any one single command failed then print "FAILED".

My shell script commands:

cd /home/lin

mkdir logs

cp /tmp/filelog.log logs/

rm /tmp/log*

touch /tmp/log

Save this file test.sh

Here is my query,

While executing this, if any one of my commands failed then it should stop execution and print "Failed"

Else print "SUCCESS"

Aucun commentaire:

Enregistrer un commentaire