Deborah R. Fowler
MS-DOS Quick Guide
Posted on Aug 21 2018Updated on April 16 2020
On many Linux and on OSX the default shell terminal language used is 'bash" (Bourne Again Shell - pun based on one of the early unix developers - Stephen Bourne).
The underlying OS on Windows evolved from MS-DOS (Microsoft Disk Operating System) and in a terminal window you can still run DOS commands. Many linux commands do not work but you can find equivalents:
Comparison of DOS versus linux commands
There also exists PowerShell which does not use DOS, and has a limited number of commands. It is designed for command-line system administration tasks. For example, ls and dir both work in the powershell but in a Command Prompt window only dir works to list files.
To access:
- Command Line Window (go to the start menu, type terminal or cmd or command and open the Command Prompt)
- PowerShell Window (go to the start menu, type power and open PowerShell)
Try typing
echo hello
It prints the word hello
cd Desktop
echo hello >> file.txt | type file.txt
In the dos shell it creates the file and prints the words on your
window. In the powershell it does not print the words but does
create the file. See images below:
echo hello >> file1.txt | cat
file1.txt
In the dos shell it
says 'cat' is not recognized as an internal or external
command, operable program or batch file.
In PowerShell it
still does not display the contents. But typing either on a
separate line, cat file1.txt or
type file1.txt or Get-Content -Path .\file1.txt the
contents of the file. Piping in PowerShell is a bit different
in that it does not pipe text but will pipe objects. Really
these are separate commands - so you can run them with a
semi-colon separating them if desired.
echo
hello > file1.txt ; type file1.txt
The above command will work in powershell,
but not in the Command Line Window
Looking at the >> symbol, this directs
the content into a file. It will append if you use >> and will replace if
you use >
Now what if you type
echo
miss piggy > file1.txt
In cmd you will get miss piggy as a single
line, in powershell, separate lines. Really we should use
quotes to get a the correct string literal.
Why show you this? To see that really,
underneath the hood, windows can look a great deal like
linux. Nautilus
is an application used on our linux system to make linux
look more like windows. It is the default file manager for
Gnome
and draws the desktop and desktop icons (ie folders).
Again a pun here - Nautilus is a type of shell.
Command line can be useful in both systems. Whether you use a scripting language like bash, python, dos, or powershell script.
My personal preference is to use python for scripting on windows.
See
examples here.