CS 330 Lecture 2 – Shello
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
domainvariables. How do I produce an
- 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
- 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.
#!/bin/sh if test -e $0; then echo 10 else echo 20 fi
#!/usr/bin/tail -r Rachael Matthew Bingo Petey F Marge N Bill Dollar
#!/usr/bin/env zsh if [ $# -ne 1 ]; then echo 'Ack!' echo "Usage: $0 dir" exit 1 fi dir=$1 zip -r $dir.zip $dir