# Calling kind geeks:  Unix/OSX file naming question (re spaces)

**URL:** <https://boards.straightdope.com/t/calling-kind-geeks-unix-osx-file-naming-question-re-spaces/310922>\
**Category:** Factual Questions\
**Created:** [July 3, 2005, 4:18pm UTC](https://boards.straightdope.com/t/calling-kind-geeks-unix-osx-file-naming-question-re-spaces/310922 "2005-07-03T16:18:19Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![istara](https://avatars.discourse-cdn.com/v4/letter/i/e79b87/32.png) [@istara](https://boards.straightdope.com/u/istara)\
**Post date:** [July 3, 2005, 4:18pm UTC](https://boards.straightdope.com/t/calling-kind-geeks-unix-osx-file-naming-question-re-spaces/310922/1 "2005-07-03T16:18:19Z")

</div>

Is there any way to render a space when using a Unix (in this case OSX, Terminal.app) command line interface?

Eg if I have a folder called “Istara files” - how do I write that in Unix?

Istara files doesn’t work  
Istara\_files doesn’t work  
Istara%20files doesn’t work

It may be that the only solution is to rename it Istarafiles, but I was hoping there was answer.

---

<div class="post-metadata">

**Author:** ![Cleophus](https://avatars.discourse-cdn.com/v4/letter/c/a88e57/32.png) [@Cleophus](https://boards.straightdope.com/u/Cleophus)\
**Post date:** [July 3, 2005, 4:28pm UTC](https://boards.straightdope.com/t/calling-kind-geeks-unix-osx-file-naming-question-re-spaces/310922/2 "2005-07-03T16:28:24Z")

</div>

You have to “escape the shell” by enclosing the folder name in quotes, like mkdir “Istara files” or use the escape character (a backslash), like mkdir Istara\ files.

---

<div class="post-metadata">

**Author:** ![istara](https://avatars.discourse-cdn.com/v4/letter/i/e79b87/32.png) [@istara](https://boards.straightdope.com/u/istara)\
**Post date:** [July 3, 2005, 4:38pm UTC](https://boards.straightdope.com/t/calling-kind-geeks-unix-osx-file-naming-question-re-spaces/310922/3 "2005-07-03T16:38:18Z")

</div>

Oh brilliant! Thank you so much - putting " " around it did it perfectly!

---

<div class="post-metadata">

**Author:** ![Saranga](https://avatars.discourse-cdn.com/v4/letter/s/d6d6ee/32.png) [@Saranga](https://boards.straightdope.com/u/Saranga)\
**Post date:** [July 3, 2005, 5:42pm UTC](https://boards.straightdope.com/t/calling-kind-geeks-unix-osx-file-naming-question-re-spaces/310922/4 "2005-07-03T17:42:06Z")

</div>

This also works in a Windows cmd window. Although it can work without the quotes for certain commands, some programs will treat the filename as seperate arguments if quotes aren’t used.

---

<div class="post-metadata">

**Author:** ![Cleophus](https://avatars.discourse-cdn.com/v4/letter/c/a88e57/32.png) [@Cleophus](https://boards.straightdope.com/u/Cleophus)\
**Post date:** [July 3, 2005, 9:47pm UTC](https://boards.straightdope.com/t/calling-kind-geeks-unix-osx-file-naming-question-re-spaces/310922/5 "2005-07-03T21:47:36Z")

</div>

> [@istara](#):
>
> Oh brilliant! Thank you so much - putting " " around it did it perfectly!

There are other characters you have to do that with as well.

The only disallowed character is a front slash, since that is the path seperator. You usually have to escape the space, backslash, hash mark (#), ampersand, star (\*), parenthesis, pipe (|), semicolon, angle brackets (\< and \>), backtick (`), tilde (~), double quote, and single quote characters. Keep in mind that you can’t escape the double quote with a double quote, so if you feel the need to make a filename with that character you have to use the backslash to escape it. You can, however escape the backslash with a preceding backslash.

Also, you can use the tab-completion to see how the shell does it. Type in part of a filename and press tab. If the shell can figure out what file you want, it will fill it in. If the shell has several candidates that match what you typed, it will show all the possibilities and beep, prompting you to fill in the rest. If the shell can’t find what you typed at all, it will beep without showing anything. If you do this to one of your space-containing filenames or other special character filenames, you will see where it escapes them with backslashes.

---

<div class="post-metadata">

**Author:** ![Cleophus](https://avatars.discourse-cdn.com/v4/letter/c/a88e57/32.png) [@Cleophus](https://boards.straightdope.com/u/Cleophus)\
**Post date:** [July 3, 2005, 10:14pm UTC](https://boards.straightdope.com/t/calling-kind-geeks-unix-osx-file-naming-question-re-spaces/310922/6 "2005-07-03T22:14:44Z")

</div>

I should also add that you have to escape the question mark as well.

---

<div class="post-metadata">

**Author:** ![snailboy](https://avatars.discourse-cdn.com/v4/letter/s/97f17d/32.png) [@snailboy](https://boards.straightdope.com/u/snailboy)\
**Post date:** [July 4, 2005, 2:29am UTC](https://boards.straightdope.com/t/calling-kind-geeks-unix-osx-file-naming-question-re-spaces/310922/7 "2005-07-04T02:29:23Z")

</div>

> [@Cleophus](#):
>
> Also, you can use the tab-completion to see how the shell does it.

Note that a few shells do not support auto-completion. Bourne shell is the only one I can think of. I’ve never seen a Linux distro where it is the default, but it is in FreeBSD except for the superuser. The superuser uses csh, which will do auto-completion if there’s only one possibility, but will not print multiple possibilities. Bash will display multiple possibilities. Zsh will even let you toggle through the various possibilities if you repeatedly press tab. So it varies significantly.

---

<div class="post-metadata">

**Author:** ![Cleophus](https://avatars.discourse-cdn.com/v4/letter/c/a88e57/32.png) [@Cleophus](https://boards.straightdope.com/u/Cleophus)\
**Post date:** [July 4, 2005, 3:43am UTC](https://boards.straightdope.com/t/calling-kind-geeks-unix-osx-file-naming-question-re-spaces/310922/8 "2005-07-04T03:43:59Z")

</div>

> [@snailboy](#):
>
> Note that a few shells do not support auto-completion. Bourne shell is the only one I can think of. I’ve never seen a Linux distro where it is the default, but it is in FreeBSD except for the superuser. The superuser uses csh, which will do auto-completion if there’s only one possibility, but will not print multiple possibilities. Bash will display multiple possibilities. Zsh will even let you toggle through the various possibilities if you repeatedly press tab. So it varies significantly.

Mac OS X, starting with 10.2, ships with bash as the default shell for all users.

---

<div class="post-metadata">

**Author:** ![Derleth](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Derleth](https://boards.straightdope.com/u/Derleth)\
**Post date:** [July 4, 2005, 8:42am UTC](https://boards.straightdope.com/t/calling-kind-geeks-unix-osx-file-naming-question-re-spaces/310922/9 "2005-07-04T08:42:16Z")

</div>

> [@Cleophus](#):
>
> Mac OS X, starting with 10.2, ships with bash as the default shell for all users.

Odd for what’s essentially a BSD, but MacOS X has never been the average BSD, now has it? 😉

(Personally, I think more distros and OSes should move to zsh as the default shell. It’s bash-compatible, it has a hell of a lot more features without being bloated on today’s powerful machines, and it’s released under the same terms as bash (the GPL). It’s very much an evolutionary change, like going from sh to bash.)

---

<div class="post-metadata">

**Author:** ![snailboy](https://avatars.discourse-cdn.com/v4/letter/s/97f17d/32.png) [@snailboy](https://boards.straightdope.com/u/snailboy)\
**Post date:** [July 4, 2005, 4:54pm UTC](https://boards.straightdope.com/t/calling-kind-geeks-unix-osx-file-naming-question-re-spaces/310922/10 "2005-07-04T16:54:24Z")

</div>

> [@Cleophus](#):
>
> Mac OS X, starting with 10.2, ships with bash as the default shell for all users.

Well I missed the fact that OS X was used in this example. For others though, it can’t be assumed that auto-completion will work with various unices.

---

<div class="post-metadata">

**Author:** ![Grievre](https://avatars.discourse-cdn.com/v4/letter/g/22d042/32.png) [@Grievre](https://boards.straightdope.com/u/Grievre)\
**Post date:** [July 4, 2005, 4:57pm UTC](https://boards.straightdope.com/t/calling-kind-geeks-unix-osx-file-naming-question-re-spaces/310922/11 "2005-07-04T16:57:53Z")

</div>

“Istara Files”, ‘Istara Files’, or Istara\ Files all work 🙂

---

<div class="post-metadata">

**Author:** ![AHunter3](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/ahunter3/32/368_2.png) [@AHunter3](https://boards.straightdope.com/u/AHunter3)\
**Post date:** [July 4, 2005, 7:00pm UTC](https://boards.straightdope.com/t/calling-kind-geeks-unix-osx-file-naming-question-re-spaces/310922/12 "2005-07-04T19:00:59Z")

</div>

What’s really fun is when you’re scripting shell commands from another environment that uses the same escape characters (e.g., AppleScript): to send an escape character you have to escape the escape!

---

<div class="post-metadata">

**Author:** ![Balthisar](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/balthisar/32/2825_2.png) [@Balthisar](https://boards.straightdope.com/u/Balthisar)\
**Post date:** [July 5, 2005, 4:13pm UTC](https://boards.straightdope.com/t/calling-kind-geeks-unix-osx-file-naming-question-re-spaces/310922/13 "2005-07-05T16:13:37Z")

</div>

> [@Saranga](#):
>
> This also works in a Windows cmd window. Although it can work without the quotes for certain commands, some programs will treat the filename as seperate arguments if quotes aren’t used.

Very helpful hint here: if you generally get rid of useless Windows icons (like the Command Prompt) icon, but still use the Start-\>Run command to start shells, note that in 2000 and XP, typing “command” no longer works properly. It’s correct to use “cmd” now. It took me two years (!!!) of frustration with not being able to escape or quote around anything before I found this out.

---

<div class="post-metadata">

**Author:** ![Derleth](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Derleth](https://boards.straightdope.com/u/Derleth)\
**Post date:** [July 5, 2005, 5:23pm UTC](https://boards.straightdope.com/t/calling-kind-geeks-unix-osx-file-naming-question-re-spaces/310922/14 "2005-07-05T17:23:21Z")

</div>

[Cygwin](http://www.cygwin.com/) is a good way to get bash (or tcsh, if you want) and a collection of other \*nix command-line tools under Windows.

---

<div class="post-metadata">

**Author:** ![istara](https://avatars.discourse-cdn.com/v4/letter/i/e79b87/32.png) [@istara](https://boards.straightdope.com/u/istara)\
**Post date:** [July 8, 2005, 8:32pm UTC](https://boards.straightdope.com/t/calling-kind-geeks-unix-osx-file-naming-question-re-spaces/310922/15 "2005-07-08T20:32:52Z")

</div>

Wow. I had never even heard of “bash” before, and only vaguely heard of “shell” but didn’t specifically know what it was, other than a text way to use the internet.

Thanks all.

---

<div class="post-metadata">

**Author:** ![Bytegeist](https://avatars.discourse-cdn.com/v4/letter/b/9dc877/32.png) [@Bytegeist](https://boards.straightdope.com/u/Bytegeist)\
**Post date:** [July 8, 2005, 8:58pm UTC](https://boards.straightdope.com/t/calling-kind-geeks-unix-osx-file-naming-question-re-spaces/310922/16 "2005-07-08T20:58:51Z")

</div>

> [@istara](#):
>
> … only vaguely heard of “shell” but didn’t specifically know what it was, other than a text way to use the internet.

It has nothing to do with the Internet specifically. In Unix jargon, a “shell” is a textual, command-line interface to the operating system’s services. Even a machine unconnected to the Net will have a shell or two available. (Unless some mischievous person has deleted all the executables.)

[More reading here.](http://en.wikipedia.org/wiki/Unix_shell)

---

<div class="post-metadata">

**Author:** ![rjung](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@rjung](https://boards.straightdope.com/u/rjung)\
**Post date:** [July 9, 2005, 12:13am UTC](https://boards.straightdope.com/t/calling-kind-geeks-unix-osx-file-naming-question-re-spaces/310922/17 "2005-07-09T00:13:57Z")

</div>

> [@Cleophus](#):
>
> The only disallowed character is a front slash, since that is the path seperator.

From the BSD UNIX side, yes. From the MacOS X side, the only disallowed character is the colon (:), which was the path separator from the original MacOS System/Finder. I imagine the file system does some translating between the two automagically, though I’ve been too lazy to check. 😉

---

<div class="post-metadata">

**Author:** ![Cleophus](https://avatars.discourse-cdn.com/v4/letter/c/a88e57/32.png) [@Cleophus](https://boards.straightdope.com/u/Cleophus)\
**Post date:** [July 9, 2005, 3:33am UTC](https://boards.straightdope.com/t/calling-kind-geeks-unix-osx-file-naming-question-re-spaces/310922/18 "2005-07-09T03:33:17Z")

</div>

> [@rjung](#):
>
> From the BSD UNIX side, yes. From the MacOS X side, the only disallowed character is the colon (:), which was the path separator from the original MacOS System/Finder. I imagine the file system does some translating between the two automagically, though I’ve been too lazy to check. 😉

The Finder changes front slashes to colons, and colons to front slashes. The Finder, or any other app, will never save a file whose true name contains a front slash. It’s impossible, as the low-level IO functions simply don’t work that way. They’ll intepret the slash as a subdirectory in which the file is being placed.

---

<div class="post-metadata">

**Author:** ![Bigang120](https://avatars.discourse-cdn.com/v4/letter/b/db5fbb/32.png) [@Bigang120](https://boards.straightdope.com/u/Bigang120)\
**Post date:** [July 9, 2005, 4:37am UTC](https://boards.straightdope.com/t/calling-kind-geeks-unix-osx-file-naming-question-re-spaces/310922/19 "2005-07-09T04:37:28Z")

</div>

> [@AHunter3](#):
>
> What’s really fun is when you’re scripting shell commands from another environment that uses the same escape characters (e.g., AppleScript): to send an escape character you have to escape the escape!

Oh is it ever! I have written an application at work that allows administrators to change the behavior of CGI programs via a CGI program. I have some routines where a CGI app takes info, makes a call to the shell to modify an existing CGI app which then has to generate dynamic output. You get great lines like

```auto

print "Hello World!\\\\\
";

```

:mad:  
Missing one backslash has some strange side effects.

---

<div class="post-metadata">

**Author:** ![Derleth](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Derleth](https://boards.straightdope.com/u/Derleth)\
**Post date:** [July 9, 2005, 5:52am UTC](https://boards.straightdope.com/t/calling-kind-geeks-unix-osx-file-naming-question-re-spaces/310922/20 "2005-07-09T05:52:34Z")

</div>

> [@rjung](#):
>
> From the BSD UNIX side, yes.

It’s reserved on Linux, too, and Linux is not a BSD in any way. I can’t imagine it _not_ being reserved on any Unix except one with a history as odd as MacOS X.

> [@Bytegeist](#):
>
> (Unless some mischievous person has deleted all the executables.)

If that’s happened, you won’t even be able to login. (Yes, login is a seperate program. And due to the magic of one-way hashes, it does _not_ need to know your actual password.)

[Next page](https://boards.straightdope.com/t/calling-kind-geeks-unix-osx-file-naming-question-re-spaces/310922.md?page=2)
