Laboratory Work 3 Operating System. Command-Line Mode
Laboratory Work 3 Operating System. Command-Line Mode
Laboratory Work 3 Operating System. Command-Line Mode
Operating system.
Command-line mode.
Methodical instructions
The user's dialog with DOS is carried out in the form of commands – strings of
characters entered by the user in response to a DOS prompt. Each user command means that
DOS must perform some action, such as printing a file or displaying the directory table of
contents on the screen.
A DOS command consists of the name of the command or program being called, and
possibly parameters. Entering each command ends with pressing the Enterkey .
The name of a command or program can be typed in both uppercase and lowercase
Latin letters (this does not matter). Parameters can also usually be written in both uppercase
and lowercase letters, otherwise this is specifically stipulated when describing a program or
command.
When DOS is ready for a conversation with the user, it sends an invitation to the screen,
such as A:\>> or C:\>>. This means that DOS is ready to receive commands.
Getting help about DOS commands
For a quick reference about a DOS program or command, you can enter this command
(program name) with the /?parameter. For example, for help with the sys program, enter the
command sys/?. The screen will display a reference about the program's purpose and the format
of its call.
Display the disk directory table of contents on the screen using the DIR command
Type MS-DOS: DIR on the command line and press {Enter}.
The screen displays a list of subdirectories and individual files in the root directory of a
disk With:. It may not fit on the screen, so repeat the command with the dir/P key.
The list will be displayed on the screen in parts. To display the next fragment of the list,
you need to press any key (for example, {Enter}).
For each folder (<DIR> specifies the date and time of creation, in the format DD. MM.
YY (day, month, year) and HH:MM (hours and minutes). For each file, specify the length (in
bytes), date and time of creation(or last update). In the conclusion, specify the volume of all
directory files and the amount of free disk space.
When working in MS-DOS, so – called file name templates-characters are often used <?
> <?><*>. Templates are used in commands to indicate multiple files at once. The * sign in the
file name or type replaces any number of characters, and the sign ? – any single character (P*.* -
all files with names starting with P, *.PAS – all files of the PAS type.
Redirecting the I / o of DOS commands
Sometimes it is convenient for the data that a DOS command or program normally
displays on the screen to be placed in a file on disk, printed to a printer, and so on. It can also be
useful if a DOS command or program takes the corresponding data from a file on the disk
instead of entering data from the keyboard. For incoming DOS commands and programs, you
can do this by using I / o redirection tools.
I / o redirection should be set in the DOS command line:
command >> file name -redirects messages that are output using the specified
command to the file. If the file already existed, it is replaced with a new one;
command > >> file name> - redirects messages that are output using the specified
command to the file. If the file already existed, messages are added to the end of that file;
team < file name -reading input data of a command (program) not from the keyboard,
but from a file;
command – command-passing messages displayed on the screen by the first command
as input data for the second command.
Create a text file
To create a text file, it is best to use any editor that can work with text files, such as the
built-in Norton Commander editor. Small text files can be typed directly from the keyboard,
although this is inconvenient. To do this, enter the copy con file name command
After entering this command, you will need to enter the file lines one by one. At the end
of each line , press the Enterkey, and after entering the last key, press the F6 key (Ctrl+Z) and
then Enter. Will be a file with the specified name.
Rename, copy, and merge files
To rename files, use the REN (Rename) command.
Command format: ren name-file1 name-file2
Параметр The file name parameter 1 specifies a name (or a template of names with the
characters * and ?) files to rename, the file name parameter2 new file name (s).
To copy files, use the COPY command.
Command format: copy file name1 file name2
or copy file name1 (directory name2)
In the copy command , you can use the names of so-called DOS devices instead of file
names, for example:
CON-console (keyboard for input, monitor for output) When typing from the keyboard
the end of the file is set as Ctrl Z or F6;
PRN printer (only as an output file).
Команда The COPY command can also be used to combine the contents of multiple
files into a single file.
Command format: copy имя-file name (+file name) file name
If the copy command is used for merging files, the command first specifies the names
of the files to be merged, using the " + " sign (plus), and then the name of the file to which the
contents of the merged files will be written.
Compare files
To compare files within DOS, there is an FC program.
The format command: fc (parameters) file name file name (Protocol file name)
You can use the * and ?characters in the names of files being compared. If the Protocol
file name is not specified, information about the files being compared is displayed on the screen.
Сравнение файлов программой The fc program can compare files in two ways.
1) Text file comparison, or line-by-line comparison. In this method, if the fc program
detects a difference in files, it tries to find after the point of discrepancy such places in these
files, starting from which they become identical again. The fc program outputs different file lines
for output.
2) A comparison of other (binary) files, or byte-by-byte comparison. In this method,
the fc program does not make any attempts to find the place in the files from which the files
become identical again after detecting differences in files. On output, the fc program outputs
different bytes in files.
To set comparison modes, you can specify one of the following parameters:
/L -line file comparison mode;
/B -bitwise file comparison mode.
Displaying and changing file attributes.
For each file, the corresponding directory entry contains not only the file name, date and
time of the last file modification, but also so-called file attributes. The file has four
attributes:read-only, hidden (system), and archived (archive). Each of these attributes can either
be set or not.
The purpose of these attributes is as follows. The read-only file attribute protects the file
from changes: to change or delete a file with this attribute, you must first remove this attribute.
The "hidden" and/or "system" attribute is used by some system files (for example, the main MS
DOS – IO files.SYS and MSDOS.SYS, - have both of these attributes). The archive file attribute
is set when creating or modifying a file and is reset by backup programs to indicate that the copy
is archived.
Thus, most files have only the "archive" attribute set. The other attributes (read-only,
hidden, or system) are usually not set.
Delete files
DELETE or DEL [disk name:] [\directory name\]<file name>
Output of the file to the screen for printing.
You can use the type command to display the file on the screen , andyou can use the
copy command to printthe file .
Command format: Type file name -displays a file from the current folder;
Command format: COPY filename . prn is the output file for printing.
The CLS command is available to clear the monitor screen CLS.
Control task
1) Using the DIR command, print the file names and their extensions from the current
directory page-by-page and compactly.
2) Displays a list of all files, ordered by file size.
3) Display the alphabetically ordered catalog listing on a page-by-page basis.
4) Print a list of all files with names starting with the letter A, ordered by file size.
5) Print all EXE files that have a file name of three characters and the last character of
the name is the letter n.
6) Get help using the Attrib command
7) Redirect the content of the response received in the previous task to a file named
file1.txt. To view the contents of the file.
8) Use the attrib command attribto set the read-only attribute for file1.txt.
9) Copy all files with the extension .SYS from disk C: to disk A:.
10) Delete all files from disk A: