0% found this document useful (0 votes)
5 views7 pages

An Exercise Using MS

The document provides a comprehensive exercise guide for using MS-DOS commands, including file management, directory creation, and editing text files. It outlines step-by-step instructions for various tasks such as creating directories, copying files, and checking file contents. Additionally, it includes a list of useful MS-DOS commands and a laboratory activity for practical application of the concepts learned.

Uploaded by

sandhyadevit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views7 pages

An Exercise Using MS

The document provides a comprehensive exercise guide for using MS-DOS commands, including file management, directory creation, and editing text files. It outlines step-by-step instructions for various tasks such as creating directories, copying files, and checking file contents. Additionally, it includes a list of useful MS-DOS commands and a laboratory activity for practical application of the concepts learned.

Uploaded by

sandhyadevit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

An Exercise Using MS-DOS

1. Use the dir command to list the contents of the root directory on the d: drive
d:\> dir
2. Invoke the MS-DOS full screen text editor utility EDIT to create a text file called
hello.txt. Follow the instructions given on the screen. The "Survival Guide" gives
instructions for using EDIT.
d:\> edit hello.txt
Enter the line
Hello World!
Use File|Save and File|Exit to save your work and to quit EDIT
3. Use the type command to display contents of hello.txt
d:\> type hello.txt
You should see
Hello World!
4. Use the md command to create (make) a new directory called mydir
d:\> md mydir
5. Use the cdcommand to change the default directory to mydir
d:\> cd mydir
6. Use dir to display the contents of mydir. It should contain no files except for
"pointers" to itself and it's parent.
d:\mydir> dir
7. Use the copy command to copy the file hello.tx in the root directory to mydir. The
target name defaults to hello.txt
d:\mydir> copy d:\hello.txt
8. Use dir to display the contents of mydir. You should see hello.txt listed.
d:\mydir> dir
9. Use md to create (make) a subdirectory for mydir called mysubdir.
d:\mydir> md mysubdir
10. Use cd to change the default directory to mysubdir
d:\mydir> cd mysubdir
11. Copy hello.txt to mysubdir. Use the mydir directory copy of hello.txt
d:\mydir\mysubdir> copy d:\mydir\hello.txt
Alternately use .. (two dots) to refer to mysubdir parent directory
d:\mydir\mysubdir> copy ..\hello.txt
12. Make a second copy of hello.txt but call it hello1.txt
d:\mydir\mysubdir> copy d:\hello.txt hello1.txt
13. Use the ren command to rename hello.txt as hello2.txt
d:\mydir\mysubdir> rename hello.txt hello2.txt
14. Check your work - display the contents of mysubdir. You should see two files :
hello1.txt and hello2.txt
d:\mydir\mysubdir> dir
15. Check that the contents of hello2.txt has not changed by displaying it.
d:\mydir\mysubdir> type hello2.txt
16 Using a wildcard delete all files in mysubdir. Be careful. Using wildcards in
dangerous so hit N to cancel the command!
d:\mydir\mysubdir> del *.*
Instead use a wild card to delete all files with a .txt extension
d:\mydir\mysubdir> del *.txt
Use the dir command to check that both files are gone
d:\mydir\mysubdir> dir
17. Return to the mydir directory
d:\mydir\mysubdir> cd \mydir
Alternately you could have typed cd ..
18. Use the dir command to view the contents of the mydir directory.
d:\mydir> dir
19. Use the rd command to remove the mysubdir directory.
d:\mydir> rd mysubdir
20. Use the dir command to check that the mysubdir subdirectory is gone
d:\mydir> dir
21. Return to the root directory
d:\mydir> cd \
22. Delete the mydir copy of hello.txt
d:\> del \mydir\hello.txt
Then check that it's gone
d:\> dir mydir
But the root copy of hello.txt is still there
d:\> dir
23. Remove the mydir from the root directory
d:\> rd mydir
24. And delete hello.txt from the root directory
d:\> del hello.txt
Ok, you are back where you started! Type
d:\> exit
to close the MS-DOS command prompt window.
DOS Command Exercises
1. Open a MS-DOS window - (a) START | PROGRAMS | MS-DOS or (b) START | RUN, enter in command.com
and press OK.
2. Change drive to the C: drive - just type C: and hit enter.
3. Create a new directory called 240temp - MD 240TEMP (or MKDIR 240TEMP) and hit enter. This is where you
will do ALL your work for these exercises.
4. Change directory to that new directory - CD 240TEMP.
5. Create a file - COPY CON FILE1.TXT. Now just hit a few random keystrokes to put anything in the file. When
finished, hit F6 and then enter. You will now see the message "1 file(s) copied" which means you just created
a file called file1.txt in the 240temp directory.
6. As a check, do the following - TYPE FILE1.TXT and you will see the contents of that file (garbage). Also do a
DIR and you will see the contents of the directory you're in (c:\240temp). You will see that file.
Exercise
Now you're ready to begin the exercises. Each numbered item has an answer in the answer key. Do the
exercises first, on the computer and while down the answers. Then consult the answer key.
1. Copy FILE1.TXT and make a file2.txt, file3.dat, file4.xyz, file5.txt. Pay attention to the names and extensions of
the files.
2. List out the directory and see ALL the newly created files.
3. Now you just want to see a list of the files that have TXT as their extension.
4. Make a copy of file4.xyz and call it first.dat
5. Create a subdirectory under the directory you're currently in. Call this new directory TESTDIR
6. Copy all the files with an extension of DAT to the new subdirectory.
7. Change directories to the newly created directory and list all the files in there.
8. Delete file3.dat.
9. Go back up to the parent directory of the current directory you are in.
10. List all the file with an extension of DAT in the current directory and the one you just created. Use only one
command to do so.
11. Change the name of file1.txt to file6.txt.
12. Delete the directory you created (TESTDIR). Are you able to do this ? Why or Why not ?
13. Change directories to the TESTDIR directory. Delete the remaining file. Change directories up to the parent
directory (up one level) and now delete the directory.
14. List all the files that start with FI and have an extension of TXT.
15. List all the files that start with the word FILE, then a single digit an extension of TXT.
When you are using a Microsoft MS-DOS command prompt shell window, you can type the following commands
into the window.
cd : Change directory or display current directory path.
cls : Clear the window.
dir : Display list of contents of current directory.
help : Display list of commands or help about a command.
notepad : Run the Windows Notepad text editor.
type : Displays the content of a text file.

Some other useful commands are:


assoc : Displays or modifies filename extension associations.
attrib : Displays or changes file attributes.
chkdsk : Checks a disk and displays a status report.
color : Sets the text and background colors.
comp : Compares the contents of two files or sets of files.
copy : Copies one or more files to another location. See also: xcopy
date : Displays or sets the computer's date. See also: time
del (or erase) : Deletes one or more files.
defrag : Defragment the specified storage device.
doskey : Display command history; define macros.
echo : Displays messages, or turns command echoing on/off.
edit : Runs the MS-DOS text editor. See also: notepad
exit : Closes the MS-DOS window.
fc : Compares two files or sets of files and displays the differences.
find : Searches for a text string in a file or files.
findstr : Search for a regular expression text string in a file or files.
goto : Used in a batch program file to jump to a particular line.
if : Used in a batch program file to perform conditional testing.
md (or mkdir) : Creates a directory.
more : Displays the contents of a file one screen at a time.
move : Moves one or more files from one directory to another directory.
rd (or rmdir) : Removes a directory.
rem : Used in a batch program file to identify comments.
ren (or rename) : Renames a file or files.
sort : Sorts input.
start : Starts a new window to run a specified program or command.
time : Displays or sets the computer's time. See also: date
tree : Graphically displays the directory structure of a drive or directory.
xcopy : Copies files and directory trees. See also: copy

V. GRADING SYSTEM / RUBRIC (please see separate sheet)

VI. LABORATORY ACTIVITY

INSTRUCTIONS:
1. Open your MS-DOS in your respective terminal.
2. Change drive to the H: drive - just type H: and hit enter. (You may your C: drive or any available drive if you
do not have access to H: drive)
3. Create a new directory called OSLAB - MD OSLAB (or MKDIR OSLAB) and hit enter. This is where you will
do ALL your work for these exercises.
4. Change directory to that new directory - OSLAB.
5. Create a file - COPY CON FILE1.TXT. Then type “Hello DOS World!”. When finished, hit F6 or CTRL+Z
and then enter. You will now see the message "1 file(s) copied" which means you just created a file called
file1.txt in the OSLAB directory.
6. As a check, do the following - TYPE FILE1.TXT and you will see the content of that file. Also typethe
command DIR and you will see the contents of the directory you're in (H:\OSLAB) including the newly
created file.

TASKS:
Now you're ready to begin. Each numbered item has an answer (answer to the question, commands used and/or
analysis and observation of the step or process).

Note:
 Capture your executed commands and their respective outputs using snipping tool.
 Save you file as SURNAME_Expt1.docx
 Upload your accomplished lab activity report to our Canvas.

1. Using copy command, copy FILE1.TXT to make the following filenames: file2.txt, file3.dat, file4.doc, file5.txt.
Pay attention to the names and extensions of the files.
Paste your captured executed commands and output below:

2. List out the directory and see ALL the newly created files.
Paste your captured executed commands and output below:

3. Now you just want to see a list of the files that have TXT as their extension.
Paste your captured executed commands and output below:

4. Make a copy of file4.doc and call it first.dat


Paste your captured executed commands and output below:

5. Create a subdirectory under the directory you're currently in. Call this new directory TESTDIR.
Paste your captured executed commands and output below:
6. Using a wildcard, copy all the files with an extension of DAT to the new subdirectory.
Paste your captured executed commands and output below:

7. Change directories to the newly created directory and list all the files in there.
Paste your captured executed commands and output below:

8. Delete file3.dat.
Paste your captured executed commands and output below:

9. Go back up to the parent directory of the current directory you are in.
Paste your captured executed commands and output below:

10. List all the files with an extension of DAT in the current directory and the one you just created. Use only one
command to do so.
Paste your captured executed commands and output below:

11. Change the name of file1.txt to file6.txt.


Paste your captured executed commands and output below:

12. Create another directory TESTDIR2 and copy the directory/folder TESTDIR to the newly created directory.
Paste your captured executed commands and output below:

13. Remove the directory you created (TESTDIR). Are you able to do this? Why or Why not?
Paste your captured executed commands and output below:
Answer:

14. Use wildcard to list all the files that start with FI and have an extension of TXT.
Paste your captured executed commands and output below:

15. Use wildcard to list all the files that start with the word FILE, then a single character and with an extension
filename of TXT.
Paste your captured executed commands and output below:

16. Check the file attributes of file5.txt. What are the given attributes?
Paste your captured executed commands and output below:

Answer:

17. Give system, hidden and read-only file attributes to file5.txt.


Paste your captured executed commands and output below:

18. Display the content of file5.txt


Paste your captured executed commands and output below:

19. Using a redirector, combine file5.txt and file6.txt content to another filename combine.txt
Paste your captured executed commands and output below:

20. Display the word “I am now a GOOD DOS USER!” on screen.


Paste your captured executed commands and output below:
16.

You might also like