Name:

class section:

    the file http://www.linux-classes.com/ccis1121-1/labs/listitems.txt should be downloaded and saved in the same directory that you are writing your shell scripts. This will provide the sample data for your first few shell scripts

  1. what command will add the variables 'sum' and 'newval' together, and put the results in to 'sum'?

  2. what command will display only the second column from listitems.txt?
  3. what command will display the contents of the variable 'sum'?
  4. (5 points) Create a shell script which uses a for loop to compute the sum of the second column of the listitems.txt file:


  5. What command will display only the 5th column of a line?
  6. Using the above command and a pipe, combine it with the ls -l command such that only filesizes are displayed.

  7. (5 points) Create a shell script wherein the previous command is combined with a for loop such that a sum of all filesizes in the current directory are displayed.


  8. (3 points) Make a copy of the above shell script and alter it so that it takes a directory name as the first argument, and computes the sum of all filesizes in that directory.


  9. (4 points) Alter the answer to the previous question such that it does not include directories in its calculations (using grep -v might prove quite useful)


  10. (7 points Extra Credit) Alter the above shell script so that it takes a second argument, which can be a file suffix (e.g. .txt. IF the second argument is present, it will include only those types of files in the sum. If the second argument is not present, it will simply look at all files(just like it did in the previous question)