Homework 7 – Shell Script

Given Sunday, November 25, 2012

Due in class on Sunday, December 2, 2012 at 600pm via ANGEL

Description:

Write a Bourne Shell Program which accepts one to many filenames on the command line. The program will compute the number of characters, words, and lines in each file. The program will also calculate the total number of characters, words, and lines found in all of the files. For this program you may NOT use the built-in "wc" program. Also, this program does not allow any switches or options on the command line. You need to perform error checking for valid filenames.

Sample Execution:

The output of the program should be as follows:

$my_wc file1 file2

 

file1 stats:

Number characters: 251

Number words: 65

Number lines: 34

 

 

file2 stats:

Number characters: 456

Number words: 89

Number lines: 67

 

Complete stats:

Total number characters: 707

Total number words: 154

Total number lines: 101