Unix Scripting

Need assistance in completing a Unix  Scripting assignment. The assignment asks to write 3 scripts


  1. Write a script that tests for a command line argument, i.e. $1.  If it is not provided, prompt the user to enter a value.  Test the user input.  If it is blank prompt the user at most two more times (3 times total).  If the input is blank all three times, exit the script with the error, ”No input supplied by user”.  Otherwise, exit the script with the output, “The user entered {userInput}, length: {length of userInput}”
  2. Write a script that simulates a game of chance.  Start the user with 25 units.  Prompt the user to [P]lay or [Q]uit.  If the user chooses [Q]uit, exit the script and output the user’s current total. If the user chooses [P]lay, deduct 1 unit from the user’s total and generate a random number between -5 and 5. Adjust the user’s total by that value.  If the user’s value goes to zero or below, output “Sorry, game over.”, and exit; otherwise, output the result, the user’s new total and prompt the user to [P]lay or [Q]uit.
  3. Write a script that takes an absolute directory path as its argument. The script should examine that directory and count the number of child directories, the number of regular files, and the number of regular files that are executable.  It should output the following:
    Results for directory: {dir}
    Number of child directories: {subdirs}
    Number of regular files: {regfiles}
    Number of executable files: {exfiles}


"Is this question part of your assignment? We can help"