----------------------- Exercise #2 for DAT2330 due September 10 ----------------------- -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: 1% of your total mark this term Due date: 12:00 noon Wednesday, September 10, 2003. The deliverables for this exercise are to be submitted online on ACADUNIX using the "submit" method described in the exercise description, below. No paper; no email; no FTP. Late-submission date: I will accept without penalty exercises that are submitted before 10h00 (10am) on Friday, September 12. After that late-submission date, the exercise is worth zero marks; but, it must still be completed and submitted successfully to earn credit in the course. Exercises submitted by the *due date* will be marked online and email sent to you after the late-submission date. A sample answer will be posted online after the late-submission date. Exercise Synopsis: This week you will be continuing to practice the "vim" text editor. You will execute some simple Unix commands, save the output, then use "vim" to modify the output and submit it for marking. References and Readings: Running Linux: Chapter 4: "Directories", "Listing Files" p.84-86 "Saving Your Output", "What is a Command" p.93-97 "Manual Pages" p.98-100 Where to work: Do your Unix command line work on the ACADUNIX computer. See last week's exercise for details on where to work. Exercise Details: 1. On ACADUNIX make a new directory under your home directory in your account. You may use any name you like; but, avoid blanks, slashes, and special characters until you know how to "quote" names properly (see file quotes.txt). 2. Move into the directory you just created. (i.e. Make the directory you just created your current working directory. See your text p.85.) 3. Run the "pwd" command (p.83,85) to verify that you are in the subdirectory you just created. Stay in this subdirectory. The outputs of the next few commands should create files in this new subdirectory (not in your home directory). 4. Following the first "du" example on p.95, redirect the output of the "pwd" command into a file in the current directory named "pwd_output". You can verify the contents of the file using: "cat pwd_output" or "more pwd_output" or "less pwd_output". 5. Try the command "ls -lh" (ref. p.86 "Listing Files"). Note the error message you get on ACADUNIX. (The "-h" option to the "ls" command is not implemented in the old ACADUNIX version of "ls".) 6. Run the command "ls -lia" (see p.86). (Remember to distinguish between the letter "l" and the digit "1".) 7. Redirect the output of the command "ls -lia" into a file in the current directory named "ls_output". (You will now have two files in this directory.) Make sure the file is not empty. 8. Create a file named exercise02answers.txt in the current directory (not in your home directory) using the VI text editor. For full marks, the spelling of the file name must be exact. At the top of the new file, create an Exterior Assignment Submission label. See last week's exercise for the details. To avoid re-typing the label, you can use VIM to read in last week's exercise file from your home directory using the pathname "../exercise01answers.txt". Use VIM to edit away the lines you don't need. 9. Following the example on p.280 "Including Other Files", insert the contents of file pwd_output at the bottom of the exercise02answers.txt file. Then also add the contents of file ls_output to the bottom of the exercise02answers.txt file. (Use the :r command to read in the first file, then use it again to read in the second file.) Make sure your cursor is on the last line of the file before you type ":r" each time. The finished exercise02answers.txt file will have the 8-line assignment label at the top, followed by the one line of pwd_output, followed by several lines of ls_output at the bottom. Separate the three sections in the file with blank lines. Save the file (write it out - see the very top of p.280). 10. Submission. Submit the completed exercise02answers.txt file for marking as Exercise 02, using the same submit procedure as last week, except, replace all occurrences of "01" with "02", e.g. $ ~alleni/bin/submit 02 exercise02answers.txt For Exercise 02, always use "02" as the first argument to "submit".