grep
The final exam will be held on Tuesday, May 20th from 3:00 - 6:00 PM.
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 quizze 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, May 8th, 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.
A normal semester has 28 classes.
But this semester has 29.
I do not have materials for a 29th class.
Next Tuesday I will have Zoom Office Hours, from 9 AM to 5 PM, instead of a class.
The Zoom session will be conducted from my home in Somerville.
Not my office on the UMB campus.
Are there any questions before I begin?
$ 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 by which called 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 forgrep
grep
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
...egrep
egrep 9\s+16 results.txt
. ^ $ * + ? { } [ ] \ | ( )
$ egrep f.d regex_test.txt fodder is for cattle $ egrep f..d regex_test.txt food for everyone $ egrep th.n regex_test.txt its a thin wafer better than ever
$ egrep e*k regex_test.txt eeeeeeeeeeeeeek!! a book is a good companion
$ egrep e+k regex_test.txt eeeeeeeeeeeeeek!!
$ egrep reads? regex_test.txt please read my book he reads well
$ egrep '\*' regex_test.txt ************* ouch
$ egrep '\*+' regex_test.txt ************* ouch
$ egrep '\d' regex_test.txt I'm in room 387
$ egrep '\d+' regex_test.txt I'm in room 387
$ egrep '' regex_test.txt food for everyone fodder is for cattle its a thin wafer better than ever eeeeeeeeeeeeeek!! a book is a good companion lease read my book he reads well 'm in room 387
$ egrep '' regex_test_2.txt
antonio34_%-+-
$ egrep '\w+' regex_test_2.txt antonio34_%-+
$ egrep '\W+' regex_test_2.txt antonio34_%-+
$ egrep '\s' regex_test_2.txt
foo
$ egrep '\S+' regex_test_2.txt antonio34_%-+ foo