CSCI 211: Unix Lab
Homework 10
(Due April 18, 2016, 23:59:59PM)

Note: 
1.	You must rely on UNIX commands only to solve the problems. No manipulation on Windows is allowed (such as scrolling the PuTTY screen). 
2.	A line of commands involving pipe ('|') or with ';' is not considered a single command.

Before doing the homework:

Run the command "source /lab10/quiz/prep.sh".

After finishing all the problems:
1.	Run the command "source /lab10/quiz/wrapup.sh". 
2.	Submit this file with your answers.
Save this file as yourlastname_yourfirstname_lab10.rtf and then submit online at http://www.networks.howard.edu/lij/courses/2016/211/

Problems:

1.	Write a bash script named "lab10.sh". The script should be invoked in the following way:
lab10.sh <repetition number>
(Configure the PATH environment variable so that you can run the script from ANYWHERE.)
When the script runs, it will do the following in order:
a)	Show the message "This script is authored by *****, Howard ID #####". Replace ***** with your full time, and ##### with your Howard ID.
b)	Check whether the first command line argument exists. If not, prompt the user to enter it, then exit.
c)	Check whether the first command line argument is a positive integer. If not, prompt the user to enter it, then exit. (To check whether a variable is a positivce integer, use the following test.)
re='^[0-9]+$'
if ! [[ $var =~ $re ]] ; then
d)	Let the first command line argument be m. Do the following operations for m times.
1)	Show the message "Please enter the path of a file or a directory:".
2)	Read the user input.
3)	Show the message "Please enter a positive integer as column number:".
4)	Read the user input.
5)	Call the function lab10sub with the two user inputs.
e)	Exit.

The function lab10sub show perform the following operations.
a.	Check whether second user input is a positive integer. If not, prompt that the second input must be a positive integer, then return.
b.	Check whether first user input is a file or a directory. If it is a file, do the following operations. If it is a directory, for each of the files in the directory, do the following operations. If neither, prompt that the first input is neither a file or directory, then return.
1)	Count the number of alphabetic words in the n-th column of the file. The path of the file is the string provided by the first input and n is the number provided by the second input.
2)	Show the message "There are x words in the n-th column of the file f.", where 'x', 'n' and 'f' should be replaced by corresponding numbers or string respectively.
3)	Count the number of integers in the n-th column of the file.
4)	Show the message "There are x integers in the n-th column of the file f.", where 'x', 'n' and 'f' should be replaced by corresponding numbers or string respectively.
5)	Return.

2.	Run the script for 4 repetitions (i.e. the command line argument should be 4). For the n-th repetition, enter the file name 'for.test.file' and column n. Copy and paste the output below.
Command used:
Output:

3.	Run the script for 1 repetition (i.e. the command line argument should be 1). For the input, enter the directory name 'for.test.dir' and column 2. Copy and paste the output below.
Command used:
Output: