CSCI 3215 (Advanced UNIX Command-Line Tools), Fall 2022:
Homework 2

Credit:
20 points.

Reading

Be sure you have read, or at least skimmed, the assigned readings for 10/03.

Programming Problems

Do the following programming (shell-scripting) problems. You will end up with at least one shell script per problem. Submit your program source (and any other needed files) by putting them in your course “TurnIn” folder on Google Drive. (Note that I want plain-text files, with or without an extension of .sh. If Google Drive balks at that, rename to have an extension of .txt. I want something I can run as is, except for possibly a change of filename. So no screenshots!) You can develop your scripts on any system that provides the needed functionality, but I will test them on one of the department's Linux machines, so you should probably make sure they work in that environment before turning them in.

Shell scripting

  1. (10 points) Do one of the following:

    1. Write a shell script that renames a file (specified as a parameter), changing any blanks in its name to underscores. If no filename is given, or if the file does not exist, the script should print an error message. Probably it should also print a message if the old and new names would be the same.

      Hint: See the examples in the class notes and the example scripts on the sample programs page.

    2. Write a shell script that makes use of a conditional (if/then/else/fi) and at least one positional parameter and does something you find useful or interesting. Include comments at the top of the script describing its purpose.

  2. (10 points) Do one of the following:

    1. Write a shell script that searches all directories in your search path for a specified file/executable and prints the directories where it is found. For example, if the script is called find-in-path, find-in-path ls would print /bin and /usr/bin or /bin/ls and /usr/bin/ls. If the specified file is found in more than one directory, the script should print them all. If it is not found at all, the script can print an error message or just do nothing. If no file/executable is specified, the script should print an error message.

      Hint: See the examples in the class notes and the example scripts on the sample programs page.

    2. Write a shell script that makes use of a loop (for or while) and does something you find useful or interesting. Include comments at the top of the script describing its purpose.

Pledge

This should include the Honor Code pledge, or just the word “pledged”, plus at least one of the following about collaboration and help (as many as apply). Text in italics is explanatory or something for you to fill in; you don't need to repeat it!

Essay

This should be a brief essay (a sentence or two is fine, though you can write as much as you like) telling me what if anything you think you learned from the assignment, and what if anything you found interesting, difficult, or otherwise noteworthy.




2022-10-23