teaching machines

CS 330 Lecture 40 – Shell scripting, or Why I love Linux

May 11, 2012 by . Filed under cs330, lectures, spring 2012.

Agenda

Code

shrinken.sh

#!/bin/sh

mkdir -p dialup_friendlies

for img in *.JPG; do
  convert $img -resize 300x300 dialup_friendlies/$img
done

checkmail.sh

#!/bin/sh

mailx -A uwec -H | grep '^ U' > /dev/null
if [ $? -eq 0 ]; then
  echo "You have mail."
fi

spam.sh

#!/usr/bin/env zsh

for username in $(cat usernames.txt); do
  echo Sending mail to $username...
  mailx -A uwec -s "[CS 330] Lecture Spam" -r johnch@uwec.edu $username@uwec.edu < message.txt
done

Haiku

Languages are streets.
Paving them smooth is pointless…
Until you’re hauling stuff.