Super User is a question and answer site for computer enthusiasts and power users. 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

If I want a series of commands to be run by terminal, instead of writing it in a text file and copying and pasting it in there, could I have terminal run it? If so, what does the extension have to be?

share|improve this question
up vote 0 down vote accepted

What you are trying to do is create a shell script with a .sh extension (Windows equivalent is a batch file with a .bat extension). Here is a simple tutorial to get you started, here is a more complex one that contains a "hello world" style introduction to shell scripting.

share|improve this answer
@typoking It won't let me use .sh. I can either use .txt or both. How do I isolate .sh? – JShoe Apr 7 '11 at 2:31
Why can't you use .sh? You said you can use ".txt or both" but .txt is only one thing... what does "both" signify? Have you already read through and tried the link to the tutorial I posted a link to? – ubiquibacon Apr 7 '11 at 2:35
Ok sorry, I fixed that by getting BBEditor. I did the chmod +x thing, but the file didn't change. I used the actual name btw. It didn't become executable. – JShoe Apr 7 '11 at 2:37
Sorry again, I figured it out on my own. Thanks! – JShoe Apr 7 '11 at 2:39
@JShoe don't be afraid to mess around try out some tutorials, you will learn a lot through the pain and suffering of figuring these things out. – ubiquibacon Apr 7 '11 at 2:43

The accepted answer is misleading. On OS X (and U*x generally), the name of the file doesn't matter at all. What matters is that it needs to have executable permission (chmod +x file) and a correct shebang line.

bash$ cat > randomness
echo Hello, world

bash$ chmod +x randomness

bash$ ./randomness
Hello, world

share|improve this answer

Just write/paste your commands in TextEdit app then save it to desktop .rtf, and once its on the desktop press on the title and rename to your preferred extension. A window will pop up asking you if you are sure you want to save as... select your option. Done. The icon should change to represent the app that can open the extension. Good luck.

share|improve this answer
He doesn't have a prefered extension, he was asking how to essentially create a batch file. – Michael Frank Mar 4 '15 at 2:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .