grepAre there any questions before I begin?
The final exam will be held on Tuesday, December 16th from 11:30 - 2:30.
The Final will be held in this room.
If for some reason you are not able to take the Final at the time it will be offered, you MUST send an email to me before the exam so we can make alternative arrangements.
60% of the points on this exam will consist of questions from the Weekly Graded Quizzes.
You do not need to study a Graded Quiz question if the topic is not mentioned in either the Midterm or Final review.
There is a link to the answers to the graded quizzes on the class web page.
The other questions I will make up specifically for this exam.
For these questions you will have to know
The last class on Thursday, December 11th, will be a review session.
You will only be responsible for the material in that review session, which you will find here, and the review for the Midterm, which you will find here.
Although the time alloted for the exam is 3 hours, I would expect that most of you would not need that much time.
The final is a closed book exam.
To prevent cheating, certain rules will be enforced during the exam.
Remember, the Midterm and Final determine 50% of your grade.
At the end of each semester we offer you the opportunity to say what you think about this course.
What have I done right?
What have I done wrong?
What can I do better?
You are not asked for you name.
So the submissions are anonymous.
I will not see your responses until after I have submitted grades for this course.
We collect this feedback through Course Evaluations.
I will use what you say to make this course better.
To complete the course evaluation, use the following link .
You have until Friday, May 23rd, to submit the evaluation.
$ dir=hw
$ echo The directory is $dir11
The directory is
$ echo The directory is ${dir}11
The directory is hw11
echo the value of $ on
the command line ...
$ echo $$ 6834 $ ps PID TTY TIME CMD 6834 pts/1 00:00:00 bash 7024 pts/1 00:00:00 ps
$ sleep 60 & [1] 7347 $ echo $! 7347
$ ./bother.sh > /dev/null & [1] 5274 $ jobs [1]+ Running ./bother.sh > /dev/null & $ echo $! 5274 $ kill $! [1]+ Terminated ./bother.sh > /dev/null $ jobs $
$ pwd /home/it244gh/it244/work $ echo $? 0 $ ls asdfasd ls: cannot access asdfasd: No such file or directory $ echo $? 2
exit built-in
$ cat exit.sh #! /bin/bash # # demonstrates the use of the exit command with a status code exit 2 $ ./exit.sh $ echo $? 2
$ cat arg_count.sh #!/bin/bash # # Prints the number of arguments sent to this script echo This script received $# arguments $ ./arg_count.sh foo bar bletch This script received 3 arguments
$ cat command_name.sh #!/bin/bash # # prints the pathname which ran this script echo This script was called using the pathname $0 $ ./command_name.sh This script was called using the pathname ./command_name.sh $ /home/ghoffman/examples_it244/command_name.sh This script was called using the pathname /home/ghoffman/examples_it244/command_name.sh
basename command ...echo Usage: $(basename $0) ...
$ cat print_positionals.sh #!/bin/bash # # Prints the value of the first four positional arguments echo 0: $0 echo 1: $1 echo 2: $2 echo 3: $3 $ ./print_positionals.sh foo bar bletch 0: ./print_positionals.sh 1: foo 2: bar 3: bletch
test command
test
[[ EXPRESSION ]]
| Operator | Condition Tested |
|---|---|
| < | The first string comes alphabetically before the second string |
| > | The first string comes alphabetically after the second string |
$ [[ "aa" < "ab" ]]; echo $? 0 $ [[ "ab" < "ab" ]]; echo $? 1 $ [[ "ab" < "abc" ]]; echo $? 0 $ [[ "ab" > "aa" ]]; echo $? 0 $ [[ "abb" > "ab" ]]; echo $? 0
| Logical Operator | [ ] | [ [ ] ] | Example |
|---|---|---|---|
| AND | -a | && | [[ $value -gt 1 && $value -lt 4 ]] |
| OR | -o | || | [[ $value -lt 2 || $value -gt 4 ]] |
$ numb=9 $ [[ ($numb -gt 1) && ($numb -lt 10) ]]; echo $? 0 $ numb=11 $ [[ ($numb -gt 1) && ($numb -lt 10) ]]; echo $? 1
$ [[ artist = a* ]] ; echo $? 0 $ [[ aa = a? ]] ; echo $? 0 $ [[ aab = a?? ]] ; echo $? 0
$ [[ artist = a* ]] ; echo $? 0 $ [[ a* = artist ]] ; echo $? 1
| p | q | p AND q |
|---|---|---|
| true | true | true |
| true | false | false |
| false | true | false |
| false | false | false |
$ cd dir1 && rm *Unix will not run
rm if cd fails
| p | q | p OR q |
|---|---|---|
| true | true | true |
| true | false | true |
| false | true | true |
| false | false | false |
grep ls $script || echo ERROR: Could not find script
grep cannot find what it is looking forgrepgrep in all my test scripts for Class Exercisesgrep on that file ...grep 55 results.txt
9 16
grep 9 results.txt && grep 16
16 9
grep ...egrepegrep 9\s+16 results.txt
. ^ $ * + ? { } [ ] \ | ( )
$ egrep f.d "fodder is for cattle" # matches fod $ egrep f..d "food is for everyone" # matches food $ egrep th.n "it's a thin wafer" # matches thin
$ egrep e*k "eeeeeeeeeeeeeek!!" # matches eeeeeeeeeeeeeek $ egrep book "a book is a good companion" # matches book
$ egrep e+k eeeeeeeeeeeeeek!! # matches eeeeeeeeeeeeeek $ egrep boo+k # no match
$ egrep reads? "please read my book" # matches read $ egrep reads? "he reads well" # matches reads
$ egrep '\*' "************ ouch"
# matches *
$ egrep '\*+' "************ ouch"
# matches *************
$ egrep '\d' "I'm in room 387"
# matches 3
$ egrep '\d+' "I'm in room 387"
# matches 387
$ egrep '\D' "food for everyone"
# matches f
$ egrep '\w' antonio34_%-+
# matches a
$ egrep '\w+' antonio34_%-+
# matches antonio34_
$ egrep '\W+' antonio34_%-+
# matches %-+
$ egrep '\s' " foo"
# matches the spaces before foo
$ egrep '\S+' " foo"
# matches foo