76

The UNIX prompt uses a $ symbol to indicate that your input is expected.

I was wondering why this symbol was chosen—if there is a reason. Dollar just seems a little unexpected. A > symbol would have been more suggestive in my opinion.

migrated from stackoverflow.com Oct 19 '09 at 23:16

This question came from our site for professional and enthusiast programmers.

  • 3
    Though not programming-related, certainly computer-related, thus better at Super User, I think. – Joey Oct 19 '09 at 23:13
  • I want to know the answer, too. I'll look for it on SU. – Gabriel Hurley Oct 19 '09 at 23:14
  • 23
    It's the Bourne shell prompt, not the Unix prompt. The default csh prompt is %. – wfaulk Oct 20 '09 at 1:58
  • 1
    wfaulk, I wish I could upvote your comment more than once. – Richie Marquez Oct 20 '09 at 2:07
  • 17
    € didn't exist yet... – mouviciel Oct 20 '09 at 8:30
54

Let's explore a little:

  • Version 8 Unix is easy. There's still man pages available. Get to the sh man page and search for prompt. You'll get to a point where you read:

    PS1 Primary prompt string, by default “$ ”.

    PS2 Secondary prompt string, by default “> ”.

  • So let's see if that was the first. Version 7 Unix man pages are still available, and the sh man page gives the same description of prompts as Version 8.

  • What about version 6? Version 6 Unix wasn't hard to track. But its sh man page doesn't mention prompts at all. The “Getting started” guide comes in handy here; it mentions:

    The culmination of your login efforts is a percent sign “%”. The percent sign means that UNIX is ready to accept commands from the terminal.

Aha! So version 6 didn't have it. Version 7 was the first! Released in 1979.

Happy? Hate to rain on your parade, but don't be :)

Problem is that version 6 was one inspiring Unix. Look at the variants here. Can it be that the $ sign as a command prompt was not started in Version 7, but instead in one of these variants and then the idea incorporated into 7?

At this point I got tired of hunting for operating systems documentation from a time when I was 6. This at least narrows it down considerably. We know Version 7 was the first Bell Labs release to show the $ sign as a command prompt. All we need to be sure is that none of those Version 6 variants introduced it. It makes sense for this change to have appeared in Version 7 though since that’s the release which introduced the Bourne shell, replacing the Thompson shell used in previous versions of Unix (and the Massey shell used in Programmer's Workbench Unix).

One last thought though:
While the idea of $ being a hint to the word shell or script is appealing and makes all sense, don't expect this to ever be officially confirmed. Unix development was shared by a rather large group of people with much bigger concerns in life than keeping track of how a symbol evolved. And some of these extraordinary programmers are not even among us anymore.

Most probably, the best you can hope to get from the question "What is the origin of the UNIX $ (dollar) prompt?" is the name of the first Unix shell introducing it.

  • 4
    Version 7 was the first Unix with the Bourne shell. It replaced the Thompson shell in Version 6. So this being a delineation between shell prompts makes sense. – wfaulk Oct 20 '09 at 1:59
  • 1
    Yup. We pretty much can trace it to the Bourne Shell. As for the author, no doubt about it. But he was an employee at Bell Labs just like everyone else. – A Dwarf Oct 20 '09 at 2:06
  • 1
    Also, there were man pages at least as far back as Version 3: minnie.tuhs.org/UnixTree/V3/usr/man/man1 – wfaulk Oct 20 '09 at 2:32
  • 2
    Back in sixth edition days and before, UNIX was distributed with full source code included. All the universities who got it tended to do local modifications (that's where BSD came from) so perhaps some local systems programmer at the University of Waterloo though that a "shell" prompt should look more like a snail, and changed the % to an @. And as you say, there were lots of variants, and when they got collated back together in v7, no doubt the origins of changes were already fuzzy. – Michael Dillon Oct 20 '09 at 17:51
  • 3
    A possible source of inspiration for Bourne: the MTS FORTRAN-IV/WATFIV manual from 1978 describes punch-card input: "control cards" include "commands ... that always start with a dollar sign ($) in column 1." – cxw Apr 16 '18 at 16:02
8

The original Bourne shell prompt was a snail shell, "@". I remember this on UNIX 6th edition which, I believe, is before UNIX was sold commercially. So the switch to a $ sign could be related to commercialisation of UNIX, as Robert suggested, $hell.

  • 3
    The Bourne shell didn't exist until Version 7. – wfaulk Oct 20 '09 at 2:20
  • 2
    Well, we just called it "the shell" so I don't really know who wrote it. I do remember seeing posters with all the shell commands documented on them, arranged in a spiral like a snail-shell or at sign. Maybe it was from O'Reilly but I can't be sure. – Michael Dillon Oct 20 '09 at 17:47
7

Sadly, I can't answer the question, but I can give you a few pointers.

6

Actually, the standard command-line prompt in Linux for a normal user account using Bourne, Bash or Korn shell is the dollar sign ($) while the root prompt is a hash mark (#). By contrast the traditional C shell prompt is a percent sign (%).

If I were to guess, the $ is reminiscent of the word $hell, which is probably why it was chosen.

  • 4
    He's asking for the actual origin, not for what people guess it might be. – davr Oct 20 '09 at 0:08
  • 6
    Don't get snarky. Judging from the other answers posted here, it appears that nobody really knows for sure anyway. – Robert Harvey Oct 20 '09 at 21:13
  • 1
    I guess the root prompt # is so chosen to coincide with the comment character, reducing the chances of accidentally pasting dangerous commands... or maybe not! I don't think they had much in the way of cut-and-paste back in the day. – Sam Watkins Mar 12 '13 at 1:22
  • For what it is worth, this was the answer I was looking for because I never can remember which is which. – John Leidegren Mar 9 at 6:50
1

Attention: this may not be true, its just a wild guess:

I have a feeling that $ is a psychological reminder.

We have to remember that back then, there wasn't a digital prompt, only a paper "teletype" (tty). And probably the dollar was to say "you're wasting paper and money keeping this phone line up. just enter some commands already!!".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.