CSC 271

Homework 2
assigned 1 Oct, due 22 Oct

In this assignment, you will write two shell scripts (in whatever shell you prefer -- sh, csh, ksh, zsh, tcsh, etc.) to "alphabetize" and "dealphabetize" the files in a directory.

What do I mean by "alphabetize", since the "ls" command already lists files in alphabetical order? Your "alphabetize" script will create a sub-directory for each (relevant) letter of the alphabet, and move all the files whose names start with "a" into the "a" subdirectory, all the "b" files into the "b" subdirectory, etc. The "dealphabetize" script will move all the files in all the subdirectories up into this directory, then delete the (now-empty) subdirectories.


panther% ls
afile	another	file1	file2	file3	file6	x-file
panther% alphabetize
panther% ls -F
a/	f/	x/
panther% ls a
afile	another
panther% ls f
file1	file2	file3	file6
panther% ls x
panther% dealphabetize .
panther% ls
afile	another	file1	file2	file3	file6	x-file

Both "alphabetize" and "dealphabetize" should take one optional argument, indicating what directory to work on. If this optional argument is omitted, it should default to "." (the current directory).

The basic program should be able to handle filenames starting with any lower-case letter.

Note: the "dealphabetize" half is probably easier; do it first. I'm not sure which of the extra credit features are easier than which.

Another note: for either half of the assignment you may need to work inside a temporary subdirectory, which you should delete as soon as you're done.

A third note: This is a difficult assignment. Start working on it now.

Last modified: Tue Oct 1 12:01:06 EDT 1996
Stephen Bloch /