teaching machines

CS 330 Lecture 2 – Shell Scripts and Redirection

January 25, 2013 by . Filed under cs330, lectures, spring 2013.

Agenda

The Unix way

Doug McIlroy said:

This is the Unix philosophy: Write programs that do one thing and do it well. Write programs to work together. Write programs to handle text streams, because that is a universal interface.

TODO

Code

doeday

#!/bin/sh

cal 28 3 $(date +%Y)

imagen

#!/bin/sh

convert -size 1600x1200 plasma: plasma.JPG
convert -size 1600x1200 plasma:blue blue.JPG
convert -size 1600x1200 plasma:tomato-steelblue tomatoblue.JPG
convert -size 1600x1200 plasma:grey50-grey50 plasma-grey.JPG
convert -size 1600x1200 gradient: grad.JPG
convert -size 1600x1200 gradient:yellow ygrad.JPG
convert -size 1600x1200 radial-gradient: cgrad.JPG

fixext

#!/usr/bin/env zsh

for file in $*; do
  mv $file ${file:r}.jpg
done

Haiku

Out is the new in
Only cool in the shell though
Don’t eat human waste