Write a program to perform set operations.

Bash -- 54 chars

case $1 in
1)rm *;w;;
2)>$2;;
3)rm $2;w;;
4)<$2;;
esac

Notes: Outputs to stdout/stderr in some scenarios. Empties working directory when clearing the set. Uses one file for each set element. The purpose of ;w is to exit with status 0.

This appears to comply with all the rules.


Python - 167 chars

import sys,shelve as S
x,A,E=S.open("x"),sys.argv,exit
A[1]<'2'and E(x.clear())or'3'>A[1]and E(x.__setitem__(A[2],1))or'4'>A[1]and E(x.__delitem__(A[2]))or E(A[2]in x)

You need to create the temporary file like this

python -c 'import shelve;shelve.open("x","c")'

bash, 74

case $1 in
1)>f;;
2)echo $2>>f;;
3)sed -i /^$2$/d f;;
4)grep ^$2$ f;;
esac

note I'm not plagiarizing Peter Taylor, it's just that it's not working with [ test ]s