------------------------ Week 7 Notes for CST8129 ------------------------ -Ian! D. Allen - idallen@idallen.ca *** Keep up on your readings (Course Outline: average 5 hours/week homework) Remember - knowing how to find out an answer is more important than memorizing the answer. Learn to fish! RTFM! (Read The Fine Manual) Review of last week: wget -O, lynx -dump grep -A1 -e foo -e bar awk -F: '{print $1}' (compare usage with cut -f 1) cmp, find, groups, mail write, mesg tr -c -d -s gzip, gunzip, zcat, zless, zgrep, bzip2, bunzip2, bzcat, bzless, bzgrep script, col -b ln Using the "ln" command to create more names for files: links_and_inodes.html Hard links and Unix file system nodes (inodes) - names are separate from the things they name - names lead to inodes, which contain the permissions and data - two or more names can lead to exactly the same inode - "ln" creates names for inodes, "rm" removes names - an inode with no names gets reclaimed ("deleted") - an empty directory has two names ("." is the second name!) - every sub-directory gives its parent a name of ".." - you can't create extra names for directories (because which name would ".." point to? ".." has to be the unique parent.) ---------- This week: ---------- Shell conditional programming exit_status.txt Return Code, Exit Status, test, if, and while - Unix commands return codes 0 to 255, with 0 meaning "success" - "exit 27" in a shell script will set the return code to 27 - shell IF and WHILE statements check return codes - the leading "!" operator complements any return code - use the "test" command (aliased as "[") to do arithmetic - "test" will also test pathname RWX and other attributes Sample shell scripts See the "Shell Scripts" section of the Course Notes for many sample shell scripts that demonstrate programming features. ---------------------- For next week (Week 8): ---------------------- Shell Variable and Command substitution: shell_variables.txt Shell Variables you should know (including $* and $@) command_substitution.txt Command Substitution - $(unix command) More shell conditional logic: quick_tests.txt Return Code, Exit Status, ||, &&, test, and if less_code.txt Less Code is Better Code - stop cutting and pasting deep_nesting.txt Avoiding deeply nested IF statements practiceTest2script.txt Practice Script #1 Specifications practiceTest2script_answer.sh.txt answer for above script_style.txt Shell Script Programming Conventions and Style script_checklist.txt Shell Script Checklist - things to verify New commands: unix_command_list.txt Basic Unix/Linux Command List