Sonoma State University
Department of Computer Science
CS-210: Introduction to Unix
Exercise 4: File processing part 1

Objective:

In this exercise, you will use some basic Unix commands to concatenate, search, and count the contents of a text file.

Instructions:

Inside your home directory, please perform the following tasks:

  • cd cs210_exercises/cs210_exercise_4
  • wget https://www.robertjamesbruce.com/programming_exercises/cs210/fall_2024/cs210_exercise_4_part_1.tgz
  • tar xzf cs210_exercise_4_part_1.tgz

Question 1:

  • Without using a text editor such as emacs, gedit, jed, nano, pico, qtextedit, vi, or vim, what exact UNIX command will concatenate chapters 5, 6, and 7 together into one file titled "CHAPTERS_5_6_7-The_Wonderful_Wizard_of_Oz.txt"?

Question 2:

  • Without using a text editor such as emacs, gedit, jed, nano, pico, qtextedit, vi, or vim, how many words are in the file "CHAPTERS_5_6_7-The_Wonderful_Wizard_of_Oz.txt"? What exact UNIX command did you use to determine this?

Question 3:

  • Without using a text editor such as emacs, gedit, jed, nano, pico, qtextedit, vi, or vim, what UNIX command(s) would create a text file containing the first 20 lines from chapter 5 and the last 15 lines from chapter 5 and saved as "CHAPTER_5-first_twenty_lines_and_last_15_lines.txt"? Note: I want the exact UNIX command(s) and correct order of those command(s) (if more than one command used) to answer the question.
  • Hint: concatenate temporary files together.

Question 4:

  • Without using a text editor such as emacs, gedit, jed, nano, pico, qtextedit, vi, or vim, how many times does the word "Dorothy" (case-sensitive) appear within the file "The_Wonderful_Wizard_of_Oz.txt"? What exact UNIX command did you use to determine this?

Submission Instructions:

  • Please submit your answers to Canvas for the questions above.

Exercise 4 Rubric

CRITERIA RATINGS POINTS
Question 1 Proficient
0.5 points

Student provided a syntactically-correct UNIX command that, if entered on Blue, would merge chapters 5, 6, and 7 together into one text file. Student's solution does not require a text editor such as emacs, gedit, jed, nano, pico, qtextedit, vi, or vim.
Satisfactory
0.35 points

Student's solution is mostly correct but contains one syntax error which prevents the solution from working as-is on a secure shell on Blue; OR the student's solution is missing one critical command-line option necessary to get the correct answer. Student's solution does not require a text editor such as emacs, gedit, jed, nano, pico, qtextedit, vi, or vim.
Needs improvement
0.25 points

Student discussed some UNIX commands that could be used but failed to provide a cohesive solution; OR the student's solution contains two or more syntax errors; OR the student's solution utilized a text editor such as emacs, gedit, jed, nano, pico, qtextedit, vi, or vim.
Below Expectation
0 points

Student provided no solution.
0.5 points
Question 2 Proficient
0.5 points

Student provided the correct answer for the number of words within the file, "CHAPTERS_5_6_7-The_Wonderful_Wizard_of_Oz.txt" and provided a syntactically-correct UNIX command that, if entered on Blue, outputs the correct number of number of words within the file, "CHAPTERS_5_6_7-The_Wonderful_Wizard_of_Oz.txt". Student's solution does not require a text editor such as emacs, gedit, jed, nano, pico, qtextedit, vi, or vim.
Satisfactory
0.35 points

Student provided a UNIX command to determine the number of words within the file "CHAPTER_5_6_7-The_Wonderful_Wizard_of_Oz.txt" and a word-count. The student's UNIX command is mostly correct but contains one syntax error which prevents the solution from working as-is on a secure shell on Blue; OR the student's solution is missing one critical command-line option necessary to get the correct answer; OR student's solution may contain an incorrect answer for the number of words within the file "CHAPTERS_5_6_7-The Wonderful_Wizard_of_Oz.txt". Student's solution does not require a text editor such as emacs, gedit, jed, nano, pico, qtextedit, vi, or vim.
Needs improvement
0.25 points

Student discussed some relevant UNIX commands that could be used but failed to provide a cohesive solution; OR student's solution contains two or more syntax errors that would fail if the command(s) were entered on a secure-shell on Blue. Student's solution may have utilized a text editor such as emacs, gedit, jed, nano, pico, qtextedit, vi, or vim.
Below Expectation
0 points

Student provided no solution.
0.5 points
Question 3 Proficient
0.5 points

Student's solution is syntactically correct and, if entered on Blue would create a file with the first 20 lines of chapter 5 and the last 15 lines of Chapter 5. Student's solution does not require a text editor such as emacs, gedit, jed, nano, pico, qtextedit, vi, or vim.
Satisfactory
0.35 points

Student's solution creates a file containing ONLY the first 20 lines of chapter 5; OR student's solution creates a file containing ONLY the last 15 lines of chapter 5; OR student's solution is mostly correct but contains one syntax error which prevents the solution from working as-is on a secure shell on Blue; OR the student's solution is missing one critical command-line option necessary to get the correct answer. Student's solution does not require a text editor such as emacs, gedit, jed, nano, pico, qtextedit, vi, or vim.
Needs improvement
0.25 points

Student discussed some relevant UNIX commands that could be used but failed to provide a cohesive solution; OR student's solution contains two or more syntax errors that would fail if the command(s) were entered on a secure-shell on Blue. Student's solution may have utilized a text editor such as emacs, gedit, jed, nano, pico, qtextedit, vi, or vim.
Below Expectation
0 points

Student provided no solution.
0.5 points
Question 4 Proficient
0.5 points

Student provided the correct answer for the number of case-sensitive occurrences of the word "Dorothy" within the file "The_Wonderful_Wizard_of_Oz.txt". Student also provided a syntactically-correct UNIX command that, if entered on Blue, outputs the correct number of case-sensitive occurrences of the word "Dorothy" within the file "The_Wonderful_Wizard_of_Oz.txt". Student's solution does not require a text editor such as emacs, gedit, jed, nano, pico, qtextedit, vi, or vim.
Satisfactory
0.35 points

Student provided a UNIX command to determine the number of occurrences of the word "Dorothy" within the file "The_Wonderful_Wizard_of_Oz.txt" as well as the number of occurrences of the word "Dorothy" within the file "The_Wonderful_Wizard_of_Oz.txt". The student's solution is mostly correct but may contain one syntax error which prevents the solution from working as-is on a secure shell on Blue; OR the student's solution is missing one critical command-line option necessary to get the correct answer; OR student provided an incorrect answer for the number of case-sensitive occurrences of the word "Dorothy" within the file "The_Wonderful_Wizard_of_Oz.txt". Student's solution does not require a text editor such as emacs, gedit, jed, nano, pico, qtextedit, vi, or vim.
Needs improvement
0.25 points

Student discussed some relevant UNIX commands that could be used but failed to provide a cohesive solution; OR student's solution contains two or more syntax errors that would fail if the command(s) were entered on a secure-shell on Blue. Student's solution may have utilized a text editor such as emacs, gedit, jed, nano, pico, qtextedit, vi, or vim.
Below Expectation
0 points

Student provided no solution.
0.5 points
Total points: 2