DOS Command Listing:
In the following section, alternative options are separated by the ‘!’ character. Arguments are optional unless in italics. ‘cwd’ stands for ‘Current Working Directory’.
DOS Conventions:
DOS commands are not case sensitive. Some commands have switches; these must be preceded by a forward slash (/). Pathnames may be precedd by a drive letter as in ‘X:pathname’ and if no drive or pathname is given the current
directory is assumed.
The Commands:
ATTRIB +!-r +!-a pathname
Display, or set!clear Read-only or
Archive attribute
BREAK on!off
display, or turn on!off increased level of ^C detection
CHDIR (CD) path
display, or change working directory
CHKDSK pathname (A: drive only)
check disk or file logical structure
/f - fixproblems encountered
/v - verbose; displays filespecs
CLS - clear screen
COMMAND path cttydev
run nested CLI from path with I/O device cttydev
/e:# - set environment size #
/p - do not invoke another CLI
/c command - run command and then enter
COPY pathname pathname
or
COPY pathname + pathname
copy or concatenate files
/v - verify writes
/a!b - preceding and all subsequent files are ascii!
binary (* filenames in source(s) and target are matched
one-to-one.)
CTTY device
change MS-DOS I/O device
DATE dd-mm-yy
display and/or set date (numerical country-dependent format)
DEL ! ERASE pathname
delete file(s) - prompts if pathname is *.*
DIR pathname
display directory - filename and/or ext default to *
/p - paginate
/w - multi-column
DISKCOPY drive: drive:
copy disk sector-by-sector rather than file-by-file
EXIT
exit nested CLI
FIND “string” pathname
find and display lines containing string in file
/v - lines NOT containing string
/c - count lines only
/n - display line numbers also
FORMAT drive: (A: drive only)
/1 - single sided
/4 - use double rather than high density (40 tracks)
/8 - use 8 sectors of each track
/n:xx - specifies xx sectors per track
/t:yy - specifies yy tracks
/v - prompt for volume label, up to 11 characters
/f:720 - format at 720 kb
LABEL drive: label (A: drive only)
display, or edit volume label - 11 characters excluding
most specials
MKDIR (MD) path
make directory
MODE
interactively configure various options
MORE
paginates screen output
e.g. type filename | more
PATH path;path;...
display or set command search path(s) to be used after
cwd
PATH;
resets default to cwd only
PROMPT string
reset or set prompt.
Characters (each prefixed by $) mean:
$=$, t=time, d=date, p=cwd, v=version, n=drive,
g=>, l=<, b=!, _=CRLF, s=leading space, e=ESC (for ANSI driver)
RENAME (REN)pathname pathname
rename file(s) within a drive - wildcards are matched
one-to-one
RMDIR (RD) path
remove empty directory
SET variable=text
display all, set or clear MS-DOS variable - accessed as %variable%
SHARE
enable networked multi-access file locking
/f:nbytes - nbytes per file, need about 20 bytes per file,
default 2048
/l:nlocks - nlocks per file, default 20
SORT pathname pathname
sort lines of file alphabetically, ignoring case, to file or stdout; reads stdin by default
/r - reverse order
/+n - on n’th character in each line, default is first
SUBST drive: path (A: drive only)
display substitutions, or substitute path by virtual drive
SYS drive : (A: drive only)
copy hidden MS-DOS .sys files from default drive
TIME hours:minutes
display and/or set time using 24-hour format
TYPE pathname
output contents of a file, with tab spacing of 8
VER
VERIFY on!off
display, or set!clear disk write verification
VOL drive:
display disk volume label
XCOPY pathname pathname
copy directory tree
/a!m - if archive bit set ! also clears in source
/d:date- modified on or after date only
/s!e - copy subdirectories if not empty ! even if empty
/p - prompt
/v - verify
/w - wait for keypress
If renamed to MCOPY it determines automatically whether
target is file or directory.
On-Line Command Help:
Full details of all DOS commands can be seen by following the command with the switch /? For example,
DIR /?
gives a listing of all DIR options.
Command Editing:
DOS commands are stored in a template and previous commands can be recalled, character by character enabling editing as required.
The template is accessed by the following keys:-
F1 - get next character from template
F2 C - get characters up to but excluding character C
F3 - get remaining characters from template
del - skip one character in template
F4 C - skip characters up to but excluding character C
ESC - clear command line
INS - toggle overwriting of template
F5 - copy command to template for re-editing
F6 - put ^Z in new template
The arrow keys may also be used to recall the previous
command.
Batch File Commands:
All DOS commands may be used in batch files. Additionally, the following commands are useful for more advanced batch processes.
Arguments for batch files are accessed as ‘%1’ to ‘%9’.
ECHO on!off!message
display echo status, turn echoing on!off (default on)
or display message
FOR %%C IN (SET of items) DO command
C is any character other than 0-9, SET is e.g. list of files
GOTO LABEL
LABEL is any line of text, usually preceded by colon (:)
in first column, which makes MS-DOS ignore it other than as a label. Terminates if label not found
IF ERRORLEVEL number command
command executed if previous command returned exit
code >= number
IF string1 == string2 command
command executed if strings match
may be negated by NOT before condition
IF EXIST filename command
command executed if file exists
may be negated by NOT before condition
PAUSE comment
comment displayed only if echo on
REM comment
remark - ignored by MS-DOS
SHIFT
shift arguments - allows access to more than 9
SpcialCharacters:
Several special characters may be used when referring to
directories and files:
\ = root directory or a directory separator
= current directory
= parent directory
Wildcard characters may be used in filenames or extensions:
? = any character
* = any tail or extension
X: - switches to current working directory (cwd) on
drive X.
File Comparison Utility:
The FC command enables comparison of two files:
FC pathname1 pathname2
compare two files, or two wildcarded sets of files
/a - abbreviate output of ASCII comparison
/b - force binary comparison (byte-by-byte)
/c - ignore case
/L - force ASCII comparison (line-by-line)
/Lb# - use line buffer of # lines
/n - display line numbers in ASCII mode
/t - do not expand tabs - default expands to spacing
of 8
/w - compress white space (tabs and spaces) to
single space (leading or trailing white space
always ignored)
/# - # lines must match to re-synchronize else
regarded different (default is 2)
I/O Control
DOS input and output may be controlled by the following control key sequences. (^ = the CTRL key).
^C - abort current command
^H - destructive backspace
^J - linefeed - physical newline to input long lines
^N - toggle copying of terminal output to printer
^P - toggle redirection of terminal output to printer
^S - suspend/restart terminal output
^X - cancel current line, and output \-CR-LF
^Z - end of file
I/O Redirection
Input and output from commands or programs can be
redirected by using the following symbols:
> send output to...
>> append output to...
< take input from...
| pipe output to next input
Example:
pipe output from command a to input of command b:
command a | command b
send a directory listing to file filename:
DIR > filename
Using The DOS Editor:
DOS includes a full-screen editor invoked by the EDIT command (with or without a filename). To use this editor type:
EDIT (filename)
The editor provides pull-down menus, operated by the keyboard or mouse, and a help facility. Note that any changes made to a file overwrites the original, no backup is created...