Ask Different is a question and answer site for power users of Apple hardware and software. 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

I saw a couple of questions about executing command line scripts? I saw that the .command and .tool extensions were mentioned. I have always used .sh. What is the difference between these different scripts? Do some extensions allow for different commands?

share|improve this question
up vote 9 down vote accepted
  • .command - (Terminal shell script) Specifically associates a shell script with Terminal. Sometimes referred to as a "Terminal File."
  • .tool - (Terminal shell script) Same as the ".command" file extension.
  • .sh - (Shell Script) A basic shell script that is associated with Xcode 4.1.

Programmatically, I'm sure the difference between the first two (.command vs. .tool) are subtle, while the third is essentially a simple, default shell script. And does in fact associate with Xcode 4.1.

enter image description here

share|improve this answer
Thanks so much for clearing that up! – daviesgeek Sep 17 '11 at 15:42
"…I'm sure the difference between the first two (.command vs. .tool) are subtle…" In fact, the differences are nonexistent :-) Terminal treats them identically. The two filename extensions map to the exact same file type in Terminal's Info.plist and Terminal does not attempt to detect which extension was supplied. In addition, apart from the fact that having different extensions means they can have different default applications, the contents of all three of these file types are the same. They are all just shell scripts. – Chris Page Sep 25 '11 at 8:15

I believe that .sh files are "owned" by Xcode by default, so if you were to double-click on one of them, it would open in Xcode instead of executing.

.command and .tool files are owned by Terminal by default, so if you double-click on one of them, it will open and execute in Terminal.

I am not aware of any other differences between them.

I, too, have used .sh for shell scripts, but I've recently stopped because I've started writing my shell scripts in Zsh instead of sh, and it was confusing to try to remember whether a certain command ended in .sh or .zsh, so I finally just put them all in ~/bin/ and made sure they were executable, and don't use file extensions on them at all.

share|improve this answer
Actually they don't open in Xcode. And I do have Xcode installed on my machine. – daviesgeek Sep 6 '11 at 2:10
.sh files can open in Xcode (control click » "open with" will show Xcode as an option), but which app they open in will depend on which application is first installed and "claims" the extension. If another app was installed before Xcode and claims .sh, it won't show as opening with Xcode. – TJ Luoma Sep 20 '11 at 2:36
You are correct: Other than the fact that the different filename extensions enable them to have different default applications, the contents and handling of these files is the same. They are all just shell script files. – Chris Page Sep 25 '11 at 8:17

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.