CS 330 Lecture 2 – Shello
Dear students,
Let’s start with some quick review questions. Discuss these questions and their answers with a neighbor. If you don’t talk to someone about these, you fail the exercise.
- Java : methods :: shell : __________
- What do strings look like in a shell script?
- Suppose I have
username
anddomain
variables. How do I produce anaddress
variable? - How do I write a loop that processes all PNG files in the current directory?
- What is the exit status of this script?
if test -e $0; then echo 10 else echo 20 fi
Then we’ll write some scripts:
- A file that reverses itself.
- Zip a directory
DIR
to fileDIR.zip
. - Bookmark a directory for later return.
- Send files to limbo/recycling bin, rather than hell/non-existence.
- Send a mass email.
Here’s your TODO list for next time:
- Read the Linux Tutorial.
Sincerely,
iam.sh
#!/bin/sh if test -e $0; then echo 10 else echo 20 fi
lines
#!/usr/bin/tail -r Rachael Matthew Bingo Petey F Marge N Bill Dollar
zippydoodir
#!/usr/bin/env zsh if [ $# -ne 1 ]; then echo 'Ack!' echo "Usage: $0 dir" exit 1 fi dir=$1 zip -r $dir.zip $dir