----------------------- Exercise #2 for CST8129 due September 14, 2005 ----------------------- -Ian! D. Allen - idallen@idallen.ca Remember - knowing how to find out an answer is more important than memorizing the answer. Learn to fish! RTFM! (Read The Fine Manual) Global weight: 2% of your total mark this term Due date: Before the end of your Lab period on Wednesday, September 14. The online deliverables for this exercise are to be submitted online via the T127 Linux Lab using the submit method described in the exercise description, below. No paper; no email; no FTP. Late-submission date: I will accept without penalty online exercises that are submitted late but before 23h00 (11pm) on Wednesday, September 14. After that late-submission date, the exercise is worth zero marks. Exercises submitted by the *due date* will be marked online and your marks will be sent to you by email after the late-submission date. This exercise is due before the end of your Lab period on September 14. Exercise Synopsis: Marks: 2% Part I - create a quick-index to common Unix command names. Many of these commands were used in your text Chapter 1. Part II - familiarize yourself with the shell's parsing of arguments, with some common utility commands, and with GLOB patterns. Where to work: Do your Unix command line work on any WT127 workstation. The files you work on will remain in your account after you log off. Do not erase your files after submission; always keep a spare copy of your exercises. WARNING: Do not attempt this exercise on a Windows machine - the text file format is different. You must connect to and work on Unix/Linux. Note that you may connect to a lab workstation *from* a Windows machine (using PuTTY); however, you may not use the Windows machine itself to do your work. Use the vim editor on the Linux machine. Location of the course notes on the Lab workstations: You can find a copy of all the course Notes files on any Lab workstation under directory: ~alleni/public_html/teaching/cst8129/05f/notes/ You can copy files from this directory to your own account for modification or study, if you like. (To avoid plagiarism charges, you must credit any material that you copy and submit unchanged as your own work.) Exercise Preparation: A. Know where to find an online copy of all the course Notes on the Lab workstations. (See above.) You can get a copy of this exercise from the course notes. B. Complete the online Course Notes readings. Any questions? See me in a lab or post questions to the Discussion news group (on the top left of the Course Home Page). C. You may find the argv.sh program (in the Course Notes) useful to tell you how many arguments the shell is passing to a command. The Week 2 notes tell you how to use it. --------------------------------------------- Exercise Details (in the T127 Linux Lab) --------------------------------------------- D. Have you done all the preparation steps? If not, go back and do them. -------------------- Part I - in-lab demo -------------------- Create a text file containing a copy of the notes file unix_command_list.txt. To the right of each of the 23 commands that have been covered in Week 1 or Week 2, write a one-line explanation *in your own words* of what the command does. Show this file to your instructor before the lab ends. (You must use your *own* words in this file.) Ignore all the commands that haven't yet been introduced. You will add to this file next week. -------------------------------------------- Part II - Answer file is exercise02text.txt -------------------------------------------- E. Using VI/VIM, edit a new file named exercise02text.txt on a Lab workstation. The spelling of the file name must be exact, othewise it won't be marked. The spelling must be exact. Exact! F. At the top of the file, create an Exterior Assignment Submission label following the example you will find under the "Assignment Standards" button on my teaching home page (teaching.idallen.com). For full marks, follow the directions for the label exactly. The label has exactly 7 lines, plus an optional Comments line. The spelling of the label fields on the seven lines must be exactly as shown. The spelling must be exact. Exact! G. Preface each of the seven lines of the label with the two characters "# " (octothorpe+space). The lines do not have to be numbered. Leave a blank line below the label. Using vim, read (copy) the following questions from the exercise file into your answer file, below the assignment label. Under each question, write your answers. (These questions are based on readings in the Course Notes, e.g. glob_patterns.txt, quotes.txt, etc.) 1. The command "env" outputs a list of environment variables. What command pipeline would count just the number of words in that output? The output on your screen must be a single number that is the word count. (Hint: See the man page for the word counting command.) 2. Put these in correct order of shell processing and expansion: redirection, quotes, GLOBs, variables 3. What keyboard sequence will interrupt the command "sleep 99"? 4. How many command arguments does the shell pass to this echo command: echo "one two" three 'four five' 5. How many command arguments does the shell pass to this echo command: echo 'It's "1 2" isn't it? I can't decide. 6. Given this long directory listing from ls: drwxr-x--x 256 ian user 512 May 30 12:35 dir What does the number 512 mean? 7. What is the output on your screen of this shell command line in an empty directory? echo * 8. What is the output on your screen of this shell command line in an empty directory? ls * 9. Given this command: wc -wc wc How many options are being passed to the word count command? 10. In an empty directory, how many arguments are passed to the rm command in this command line: touch a1 b2 out o1 .oo ; rm o* 11. If directory /a contains these seven two-character file names: aa, ab, ac, ad, a*, a?, ??, then which shell command will remove only the single name a? from the directory? 12. If directory cow contains only these four three-character file names: .AA, .A1, .BB, .B., then what is the output on your screen of this command line: echo cow/* 13. Which command line displays all the names in the current directory that are exactly three digits long (and no others)? 14. In an empty directory, how many files are created by this command: touch a "b c" ' ' d e 15. Which command line displays all the non-hidden names in the current directory that contain the letter x (and no others)? 16. Describe the output on your screen of the following command sequence if run in a directory containing 123 files with names that are all the numbers from 1 to 123 inclusive: glob="*" ; echo "$glob" 17. How many arguments (file names) are passed to the touch command in this command line: x="a b c" ; touch $x 18. True/False - your login home directory is a sub-directory of the system directory named "/home". 19. True/False - your current directory is always a subdirectory of the system directory named "/home". 20. How many lines of output are produced on your screen by searching for the keyword "password" in the title lines of manual pages? Submission ---------- Submit the finished and labelled exercise02text.txt file for marking using the following Linux command line: $ ~alleni/bin/copy exercise02text.txt This program will copy the selected file to me for marking. You can copy the file more than once. Only the most recent copy will be marked. P.S. Did you spell all the label fields and file names correctly?