What does the $ mean when running commands?
Asked Answered
C

5

15

I've been learning Python, and I keep running into the $ character in online documentation. Usually it goes something like this:

$ python ez_setup.py (Yeah, I've been trying to install setup tools)

I'm fairly certain that this command isn't for the python IDE or console, but I've tried windows cmd and it doesn't work. Any help?

Cachet answered 14/11, 2013 at 19:13 Comment(0)
R
22

As of now, Python does not implement $ in its syntax. So, it has nothing to do with Python.

Instead, what you are seeing is the terminal prompt of a Unix-based system (Mac, Linux, etc.)

Reaper answered 14/11, 2013 at 19:14 Comment(2)
Okay, I see that it's windows command prompt now. But it's not recognizing these commands; I saw this youtube.com/watch?v=i1AQZDPru8Q#t=51, and it's command prompt, but it seems the directory part (the one generalized to $ online) has been changed to the python directory. How would I do that?Cachet
Sorry, I was getting ahead of myself. I meant the '$''s dos equivalent, 'C:\~' wasn't accepting the commands, but I figured out I just hand to change the directory to make it work. Thanks!Cachet
A
13

When you open up command prompt in Windows, you'll see something like:

C:\Users\Michael0x2a\Blah> 

The $ symbol is the equivalent in Linux-based systems.

Whenever you see the $ sign, simply ignore it and type in the rest of the line without modification.

Acherman answered 14/11, 2013 at 19:18 Comment(0)
V
6

The $ is the command prompt. It is used to signify that python ez_setup.py should be run on a command line and not on a python/perl/ruby shell

You might also see % python ez_setup.py, which also means the same thing

Vaudois answered 14/11, 2013 at 19:14 Comment(1)
or > python ez_setup.py ... although thats less common because it looks more like the python shell ... but often time they are just copy/pasting their command promptZug
C
3

As the two previous answers told, $ is the beginning of commandline prompt waiting for your input in Unix/Linux -systems. In Windows the similar example notation would be like

C:\> python ez_setup.py

So you don't have to write the dollar sign. Just imagine the beginnings of Windows CMD or Powershell prompt in the beginning of line :)

You can read more discussion about the history of dollar sign from Superuser.

Conterminous answered 14/11, 2013 at 19:20 Comment(0)
M
1

The Odin Force Project clarified the use of $ quite nicely in their Foundations lesson:

[T]ake a look at the following text: $ whoami This is a terminal command because it begins with a $. The $ is saying “Hey! Enter what follows in your terminal.” This means that we must exclude the $ when entering any command. In the example above, we would only enter whoami in our terminal. This is a common indicator so make sure that you aren’t entering $ before a command.

Moray answered 8/5, 2022 at 19:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.