shell script shirt

How to create an executable shell script in OSX or Linux

I am a complete novice at times when it comes to shell commands. So there are some commands that are SO basic, that I should feel ashamed to blog about them… but this site is just as much for my reference as it is for yours 😛

  1. Make a text file in a text editor
  2. Type some commands in it as you would manually in your terminal
  3. Save the file as something like your-file-name.sh
  4. In terminal, navigate to yoru saved file and type chmod a+x your-file-name.sh
  5. When you want to run this script, navigate to it and type ./your-file-name.sh  (It is very important to prefix your file with ./ or else it won’t execute.)

Leave a Reply

Your email address will not be published. Required fields are marked *