------------------------ Week 9 Notes for DAT2330 ------------------------ -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) ------ Review ------ In Week 8 (week08notes.txt): You learned to program IF/ELSE/FI statements. You learned to program WHILE/DO/DONE statements. You know the "test" command and six numeric comparison operators. For "test" you know two string comparison operators: = != For "test" you know seven file operators: -e -f -d -s -r -w -x For "test" you know how to negate a test and use AND and OR boolean operators. You know how && and || work to separate Unix commands based on return code. You know what the commands "true" and "false" do. You recognize "[" and "]" as a syntactic sugar synonym for "test". You can use input redirection with "wc" to avoid outputting the file name. You can compile a single-file C or C++ program, with warnings enabled. ------------------ This Week (Week 9) ------------------ * Unix/Linux Final Exam Friday March 12 Your Linux final test takes place in your lecture class on Friday this week. The test is on paper. The format is many multiple-choice questions and some script writing. (Bring pencils and erasers.) Ask your questions in the lab this week in preparation for the final exam on Friday. You can also post to the Discussion News group. * Practice script writing in Lab this week I will develop the solution to a typical final exam script question. You will follow along and hand it in at the end of your lab period. * Textbook readings: Nothing new this week - make sure you have read and understood all the sections from previous weeks in preparation for your final test this week. * New Notes readings: practiceTest2scriptA.sh.txt - rough solution to the Practice Test Script practiceTest2scriptB.sh.txt - better solution to the Practice Test Script practiceTest2script.txt - Practice Test Script practiceTest2.txt - ASCII text version of Practice Test #2 practiceTest2.pdf - PDF version of Practice Test #2 practiceTest2.ps - Postscript text version of Practice Test #2 All the *.sh.txt script examples. * Start DAT2330 Exercise #4 (final Unix script project). (Project details have yet to be announced.) Important Notes for the Unix Final Exam and Exercise #4: - Read the weekly notes and do the readings! - Use variables to hold constants (like you use #define in C) - reduce maintenance: how many edits needed to change a constant? - DOUBLE QUOTE ALL VARIABLES to protect contents from unwanted shell GLOBbing. Double quotes permit the shell to expand the variables; but, they stop GLOB metacharacters from being expanded. - Remember to quote command line arguments if they contain shell metacharacters that you do not want the shell to process (e.g. GLOB characters such as ? * []). - All quoted strings are always part of one single argument, except for the one "$@" special case (see shell_variables.txt for details). - Use Command Substitution as needed. - Follow the exact 9-part format described in Notes files script_style.txt and script_checklist.txt. Scripts without comments are worth zero marks. You must document what you do.