Tags: /
dos windows terminal
/
—
As seen in Windows XP.
Similar commands. Not exact same ones. There are differences.
Linux | DOS |
---|---|
ls | DIR |
cp | COPY |
cd | CD or CHDIR |
pwd | CD |
clear | CLS |
cat | TYPE |
edit | Launch editor |
rm | DEL or ERASE |
echo | ECHO |
man | HELP |
diff | FC |
rmdir | RMDIR or RD |
mkdir | MKDIR or MD |
chmod | ATTRIB |
grep | FIND (and FINDSTR ?) |
free | MEM |
more | MORE |
mv | MOVE |
ping | PING |
sort | SORT |
date | DATE |
Options in DOS start with /
as in /a
instead of -a
in Linux.
Help text of DOS commands is usually obtained using /?
, like --help
in Linux.
With FC
command. As in 'File Compare'.
fc file1.txt file2.txt
Or with COMP
command which is a bit different from FC
.
Launch an editor.
edit [file]
MS-DOS editor in XP.
MS-DOS editor not available in any 64-bit Windows.
mkdir [dirs]
md [dirs]
Remove an empty directory.
rmdir [dirs]
rd [dirs]
Or remove entire directory along with all its sub-directories and files with DELTREE
:
DELTREE
is considered a 'dangerous' command due to the possibility of accidental file deletion.
CD
command.
Go to the parent directory
cd ..
Run cd
without any parameters.
cd
In DOS, /?
fulfills the function of --help
in Linux.
cmd /?
HELP <command-name>
In DOS, options are preceded by a '/' unlike Unix where hyphens are used instead.
Use ATTRIB
command.
+h
: hidden+r
: read-only+s
: system file+a
: archived file-h
: not hidden-r
: not read-only-s
: not system file-a
: not archived fileFor example, the following command makes the file file.txt
'not hidden' and 'not read-only'.
attrib -h -r file.txt
Without any switches, ATTRIB
acts something like ls -l
in Linux.
Two ways:
REM
command::
These work only when at the beginning of a line.
Example:
REM Hello script
:: Another comment
echo "Hello"
If we need comment after a command, we can use command concatenation character (&) like
echo "hello" & REM A comment
echo "world" & :: Another comment
MEM
command.
mem
and get output like
655360 bytes total conventional memory
655360 bytes available to MS-DOS
633456 largest executable program size
1048576 bytes total contiguous extended memory
0 bytes available contiguous extended memory
941056 bytes available XMS memory
MS-DOS resident in High Memory Area
MORE
command.
Displays search path for executable files.
Like displaying or setting $PATH
in Linux.
Suspends execution and by default, displays a "Press any key to continue . . ." message, till a key is pressed.
Two ways:
Using SET
command.
set var=hello
echo %var%
%cd% : Like $PWD in Linux
%date%
%time%
Unlike Unix, DOS considers file extension quite important.
REM Like `ls *` in Linux
dir *.*
and
REM Like `ls *.txt` in Linux
dir *.txt
*.sw?
would match ab.swp
, 12a.swo
, etc.
Display current date and prompt for new date value: date
Just display current date: date /t
Likewise with time: time
and time /t
.
Like in Unix.
For example, the following is like cat file.txt | more
in Linux:
type file.txt | more
Todo: Todo
Todo: XCOPY
command.
Change title of command prompt window with TITLE
command.
VER
command.
grep -r
dir *.txt /s /b
/s
look in all sub-directories and /b
keeps output concise.