teaching machines

CS 330 Lecture 2 – Shell Scripting

January 24, 2014 by . Filed under cs330, lectures, spring 2014.

Agenda

TODO

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.

Code

newfunc

#!/bin/sh

echo "jfaksdfhaskfhasdkjfhsadkfjhasdkjfs"

exit 7

bigfiles

#!/bin/sh

du | sort -rn | head

safe_rm

#!/usr/bin/env zsh

mkdir -p ~/.junkies
for i in $@; do
  mv $i ~/.junkies/${i:t}.$RANDOM
done

massmailer

#!/usr/bin/env zsh

for i in $(cut -f2 -d, here.txt); do
  echo "Delete this." | mail -s "[CS 330] Real Good Price on Stuff" -r johnch@uwec.edu $i@uwec.edu
done

Haiku



It’s not to save time
My brain dies a little bit
When I use my mouse