CLI Symbols

CLI Symbols

Command Line Symbols

To use the Command Line effectively you need to know some of the symbols. Like the keystrokes many of these are applicable to the regular CMD Command Prompt as well as PowerShell.

Just as the Windows GUI has many symbols - in the form of icons, toolbar buttons, etc - that you basically have to memorize so too does the Command Line. Except you can't hover your mouse over them to see tool-tip, and as just one or two characters they may be even more obscure at first. But like standard icons, CLI symbols are mostly standardized in their use.

You won't need to know/use all of these just now but the more common ones are nearer the top:

Symbol Description
.  (dot) The . (dot / period) represents the current directory; thus .\file2.txt means the file2.txt in the directory you are in.
If you are IN c:\temp\folder1\folder2 then . means folder2, and .\file2.txt means c:\temp\folder1\folder2\file2.txt
..  (double dot) The .. (double dots) represents the parent directory (one level up). You can cd .. to move up a directory.
If you are IN c:\temp\folder1\folder2 then .. means folder1, and ..\file1.txt means c:\temp\folder1\file1.txt
\  (backslash) The \ (backslash) represents the root directory of the drive. It's also used to separate directories and files in paths.
If you are IN c:\temp\folder1\folder2 then \ means c:\, and \file3.txt means c:\file3.txt
~  (tilde) In PowerShell the ~ (tilde) represents YOUR home directory, wherever that is.
If you are logged in as bsmith then ~\Desktop probably means c:\users\bsmith\Desktop. It doesn't have a basic use in CMD/DOS.
#  (hash) In PowerShell the # symbol starts a comment which is ignored in scripts. Does nothing in CMD/DOS, in batch files use REM.
<# Long comments can cross lines and are enclosed with opening and closing sets of symbols #>
|  (pipe) The | (pipe) is used to send the output of one command as the input of the next command. While CMD supports this, PowerShell uses it a lot.
Eg: dir | select Name, Length | fl (The output from dir goes into select which goes into fl and finally displays it)
>  (greater) The > (greater than sign) is used to send the output of a command into a text file, eg. dir > file.txt
This is the "cheap" way of saving output; use >> (two greater signs) to append output, as using just one > overwrites!
*  (star) The * (or asterisk) is used as a simple wildcard representing ANY number of characters. So dir *cat.txt finds all .TXT files whose filenames end in cat
(eg. tomcat.txt, nicecat.txt, but not catalog.txt). Whereas *cat*.txt would find anything with "cat" in the filename like tomcat2.txt
?  (question) The ? (question mark) is used as a simple wildcard representing any ONE character. Not used as much as *
But you will see it used as an abbreviation for the where command in PowerShell cmdlet.
%  (percent) In DOS/CMD the % (percent sign) is used around variables, like %windir%
In PowerShell the % is sometimes used as an abbreviation for the foreach cmdlet.
$  (dollar) In PowerShell the $ (dollar sign) is used to indicate a variable, so $PWD is a variable holding "the current directory".
Another common built-in variable is $_ which is the implied pipeline variable, and $PSVersionTable shows what version of PowerShell you're using.
" and '  (quotes) The " (double quote) and ' (single quote) are used to enclose strings of characters, especially if there's a space in them. So My File.txt would be two items,
but "My File.txt" is a single item. Use "double quotes" most often, esp. if you want variables to show their values in PowerShell.
-  (dash) The - (dash) is used to start all PowerShell options/parameters/switches on commands, and often for CMD/DOS too (along with the forward slash: /)
So -Identity denotes the Identity parameter. In CMD it might also be /identity (in Linux/macOS the /forward/slash/ is used to separate paths instead of the \back\slash\)
;  (semicolon) The ; (semicolon) is used to separate commands on the same line in PowerShell. So instead of cd \ (press enter) dir (press enter)
You can type cd \ ; dir and PowerShell will execute both (change to the root and show the contents of the root).
&  (ampersand) The & is the command separator in DOS/CMD (so cd \ & dir would be two separate commands on one line).
In PowerShell it invokes/starts a command or script, especially one with a space in the name, you'll see it with Tab completion.
`  (backtick) or
^  (caret)
These are "escape" characters, which means the shell ignores the next character's special meaning.
Use the backtick ` in PowerShell to escape, and the caret ^ in CMD/DOS to escape the next character.
( ) [ ] { }
(brackets)
The various brackets: (parentheses), [square brackets], and {curly braces} are used for various things primarily by PowerShell,
such as grouping commands. The main thing is that they come in matching sets, and are not interchangeable. (something] won't work.