Create a file which when opens and writes a line in Terminal Is there any way to create a file which, when clicked, opens up Terminal and types in and executes a specified line? (eg: say hello world)
What you are trying to do is write a "shell script" (in case you need to google it later on).

The first line of a shell script needs to specify what interpreter to use. In your case, use sh for the regular Bourne shell. You write this with what's called a 'shebang' like so:

#!/bin/sh


after this write whatever commands you want to run, in your case, say hello world. The shell interpreter will read this the same as if you had typed it in terminal.

In your case, your final file should be:

#!/bin/sh
say hello world


If you write this in TextEdit.app make sure you are saving in plain text mode (which is toggled through Cmd + Shift + T). You can choose to save with either the extension .command or .sh.

If you want to run it by double clicking I recommend the .command extension.

And that's it!

Possible error: if when running it you receive an error saying:


  The file “[filename]” could not be executed because you do not have
  appropriate access privileges.


you need to give yourself execute permission. To do this run:

chmod u+x path/to/my/file


If you don't know what the file-path is just type:

chmod u+x


type a space, and drag the file into the window.

If you're curious, u+x means give user (owner) execution rights.