======================================== DAT2330 Review #1 - Basic Shell Concepts ======================================== -IAN! idallen@ncf.ca This review file uses the "argv.sh" script that displays the number of arguments passed in from the command line. Download this program to your home directory and make it executable. You can find the program here: 1) URL: http://www.idallen.com/teaching/dat2330/03w/notes/argv.sh.txt 2) ACADUNIX: ~alleni/public_html/teaching/dat2330/03w/notes/argv.sh.txt or: ~alleni/course/dat2330/03w/notes/argv.sh.txt 3) idallen-linux: ~dat2330/03w/notes/argv.sh.txt 4) Floppix or at Home: get a copy by using ftp to one of the above machines Rename the program to "argv.sh" and make it executable after you copy it. To execute the program from anywhere, you can use this alias: $ alias argv="$HOME/argv.sh" The command lines below use the above alias. --------- $ argv one $LOGNAME three EXPLAIN: what output here? $ argv "one" "$LOGNAME" "three" EXPLAIN: what output here? $ argv "one" "$LOGNAME" "three" EXPLAIN: what output here? $ argv "one $LOGNAME three" EXPLAIN: what output here? $ argv "one $LOGNAME three" EXPLAIN: what output here? $ argv 'one $LOGNAME three' EXPLAIN: what output here? $ argv 'one' '$LOGNAME' 'three' EXPLAIN: what output here? $ argv ''one'' EXPLAIN: what output here? $ argv ""''one''"" EXPLAIN: what output here? $ argv ''""''one''""'' EXPLAIN: what output here? $ argv '$LOGNAME' EXPLAIN: what output here? $ argv ''$LOGNAME'' EXPLAIN: what output here? $ argv ""''$LOGNAME''"" EXPLAIN: what output here? $ argv ''""''$LOGNAME''""'' EXPLAIN: what output here? $ argv ''one'' ''$LOGNAME'' ''three'' EXPLAIN: what output here? $ argv '''one''' '''$LOGNAME''' '''three''' EXPLAIN: what output here? $ argv ''''one'''' ''''$LOGNAME'''' ''''three'''' EXPLAIN: what output here? $ argv 'one' '$LOGNAME' 'three' EXPLAIN: what output here? $ argv 'one argument '" still one argument (no shell-visible blank)" EXPLAIN: what output here? $ argv 'one argument' "now this is a second argument (shell sees a blank)" EXPLAIN: what output here? $ argv 'one '" two "three' four'" five "six EXPLAIN: what output here? $ argv '$LOGNAME'"$LOGNAME"$LOGNAME'$LOGNAME'"$LOGNAME"$LOGNAME EXPLAIN: what output here? $ argv "It's single quotes that" 'protect "all" of the metacharacters.' EXPLAIN: what output here? $ argv "It's single quotes that "'protect "all" of the metacharacters.' EXPLAIN: what output here? $ argv "It's not what you think '$LOGNAME'; look again." EXPLAIN: what output here? $ argv 'It is not what you think "$LOGNAME"; look again.' EXPLAIN: what output here? $ argv 'You must think like the '"$SHELL." EXPLAIN: what output here? $ argv 'one $LOGNAME' three ' four ' 'five'"six"seven EXPLAIN: what output here? $ mkdir empty $ touch empty/file $ ls empty EXPLAIN: what output here? $ mv ./empty/file empty/otherfile $ ls empty EXPLAIN: what output here? $ rm ./empty/./otherfile $ ls empty EXPLAIN: what output here? $ mkdir empty $ touch empty/file $ mv ./empty/file empty/../newfile $ ls empty EXPLAIN: what output here? $ echo "Where did the file go?" $ touch empty/another $ mv ./empty/another empty/../empty/mover $ ls empty EXPLAIN: what output here? $ mv empty/mover ./empty/../empty/.. $ ls ./empty EXPLAIN: what output here? $ echo "Where did the file go?" $ mkdir empty $ date >empty/out $ sort empty/out >empty/out $ cat empty/out EXPLAIN: what output here? $ wc empty/out EXPLAIN: what output here? $ mkdir empty $ date >empty/out $ wc empty/out >empty/out $ cat empty/out EXPLAIN: what output here? $ wc empty/out EXPLAIN: what output here?