OCCC CS2183 April 17, 2008

Shell Scripting Programming Homework

Due May 1, 2008

 

Please printout both the source code and the output of the command.  Your source code should contain comments and look professional.

 

 

  1. (25%) Write a shell script that take a variable number of arguments, then list out the arguments and the total number of arguments.  For example:

 

listarguments.sh every good boy deserves fudge

argument1 = every

argument2 = good

argument3 = boy

argument4 = deserves

argument5 = fudge

The total number of arguments is: 5

 

 

  1. (25%)  Write a shell script that take a directory as an argument, then report the 10 largest files, the 10 smallest files, and the total number of files in that directory, including any subdirectories.  Hint: use: find . –type f –exec du –b {} \; | sort –n

 

  1. (25%) Write a number guessing program to where the program generates a random number then ask you to guess it.  The program should reply with either higher, lower, or correct.  The program should repeatedly prompt you until your correctly guess it.  The program should then display how many guesses you took to determine the correctly guessed number.

 

  1. (25%) Create a couple of additional users in your Linux system.  Login as those new users and create some files. Write a program that lists all the users in the /home directory, and for each user, list the amount of disk space (in bytes) and all the current running processes.