CSC 271
Homework 2

Write two csh aliases.

The first, freq, stands for a pipe that counts the frequency of words in stdin and outputs a list of the words, in decreasing order of frequency, with each output line consisting of a word, some white space, and a number. Try to get the numbers right-justified if you can. You'll need either sed or awk.

The second, avgsize, stands for a pipe (or however you choose to do it) that takes a directory name as an argument and computes the average number of bytes in non-directory files in that directory. For example, if the "ls -l" command gave the output

    total 52
    drwxr-xr-x   7 sbloch   system      1024 Nov 21  1996 examples
    drwxr-xr-x   2 sbloch   system       512 Oct 12  1995 fall94
    drwxr-xr-x   3 sbloch   system       512 Sep  4  1996 fall95
    drwxr--r--   3 sbloch   system       512 Aug 26 14:34 fall96
    -rw-r--r--   1 sbloch   system      4865 Oct  7 09:18 hw2.html
    -rw-r--r--   1 sbloch   system      4865 Oct  7 09:18 index.html
    drwxr-xr-x   2 sbloch   system      1024 Sep 12 11:54 syllabus
    -rw-r--r--   2 sbloch   users      11812 Sep 12 11:54 syllabus.dvi
    -rw-r--r--   2 sbloch   users      10418 Sep 12 11:53 syllabus.tex
    drwx------   2 sbloch   system       512 Nov  9  1995 test
    -rw-r--r--   1 sbloch   system     13070 Aug  8  1994 unix.editorial
then the output would be 9006 (i.e. (4865+4865+11812+10418+13070)/5). You'll probably need awk; if you put your awk program into a separate file, please turn in that file along with your alias command that invokes it.
Last modified: Tue Oct 7 14:07:48 EDT 1997
Stephen Bloch / sbloch@boethius.adelphi.edu