Introduction
Announcements

Schedule
Labs
Assignments
TA office hours

Tests, exam

Topic videos
Some course notes
Extra problems
Lecture recordings

Discussion board

Grades so far

5. Recall the version of the 'for' syntax in which you type "for" and a variable name, but nothing else on the line: This goes through all command-line arguments. Write a shell script in sh which goes through its command-line arguments (which are supposed to be file names) and deletes (with 'rm') all files which contain (according to grep) the string "spatula".

Solution:

for i
do
    if grep spatula "$i" >/dev/null
    then
	rm "$i"
    fi
done
Notes:


[sample midterm from Winter 2011]