Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Coming from GUI interfaces I've come to finally understand the power of having everything piped in text, but I don't really know how to use all that power yet.

I realized the workflow for a particular project goes like this...

# compile repo 1
cd ~/workspace/repo1
make -B
# deploys compiled code into repo2
make deploy

# commit repo 1
cd ~/workspace/repo1
git add .
git commit -m "changes"
git push origin master

# commit repo 2
cd ~/workspace/repo2
git add .
git commit -m "changes"
git push origin master

My question isn't so much how to accomplish this, it's what is the right tool for this? Reading around it seems that a Bash script is what I need, but I'd like to know from the experts.

share|improve this question
up vote 7 down vote accepted

You've got a very good start by typing it all into one place.

Copy all of that into a text file (e.g., workflow.sh, but the name doesn't really matter) then put this on the very first line of the file:


You now have a shell script. Make it executable:

chmod +x workflow.sh

Now you can run it like a command:


It will execute each of those commands in order just by calling the workflow.

You are now a beginner system programmer. You can only go up from there.


To specify changes without having to edit the script every time you should change:

git commit -m "changes"

To read:

git commit -m "$1"

You can then pass changes in as a command line argument:

./workflow "Describe changes made"

Another useful tools are aliases and PATH. You can create a special directory (for example ~/bin) and put all scripts there, add this dir to your PATH variable and you don't need to type the full path to script every time you want to launch it. In case with aliases you need to create alias per each script, however sometimes alias is more comfortable due to you can specify different run parameters in it.

share|improve this answer
Thanks! Would the script stop executing if it received an error, say, git rejects my changes because I haven't pulled yet? – Duopixel Jun 27 '12 at 19:35
No, it would just do the next thing on the list (as if you blindly typed it into the terminal). What you're asking about is called flow control. Learning how to do that is your next step but it's a larger topic than I can write about here. Try a Google search. – bahamat Jun 27 '12 at 19:42
@Duopixel put set -e next line after she-bang and script won't continue if error occurs. – rush Jun 27 '12 at 19:46

You can organize your code with python utils: https://wiki.python.org/moin/FlowBasedProgramming

Another package not mentioned above but still promising is Snakemake.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.