I have a script which runs
rsync
with a Git working directory as destination. I want the script to have different behavior depending on if the working directory is clean (no changes to commit), or not. For instance, if the output of
git status
is as below, I want the script to exit:
git status
Already up-to-date.
# On branch master
nothing to commit (working directory clean)
Everything up-to-date
If the directory is not clean then I would like it to execute some more commands.
How can I check for output like the above in a shell script?