Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Below is the sample text --- Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard

image text in transcribedBelow is the sample text

---

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

Where does it come from? Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.

Why do we use it? It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).

Where to get this from? There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.

1. Download sample_text.txt and put it into your lab_3 folder. 2. Create a new script file "TestFile.sh" inside your lab_3 folder. 3. You need to send sample_text.txt' as an argument/parameter while running this script. 4. Retrieve the argument name in the script file and check if the file (sample_text.txt) exists using an if-else structure. If the file does not exist, echo an error message to the user and exit the program (use exit). 5. If the file (sample_text.txt) exists, display a menu using case statements. Each menu item option should call a function (listed below). You must use the bash commands that were covered in class for all of the functionality within the program (sed, awk, grep, mv, etc). Available functions for the case statements are: o count_lines() - This function will count the number of lines in the file (using sed or awk or grep). Use echo to display the resultumber of lines to the screen (e.g. the number of lines in the file is..."). o count_words() - This function will search for all instances of the words: Lorem, model, Ipsum, will within the sample_text.txt (using sed or awk or grep). Use echo to display the lines from the file where the words are found. o add_text() - This function will prompt the user to enter a sentence and then the script should append the sentence to the end of the original text file sample_text.txt. Do not create a new text file during this process. The aforementioned sentence should be appended to the original sample_text.txt file. o copy_and_exit() - This function should create a new folder named solution within the same directory as the TestFile.sh script. Next, this function should use the cp command and copy the original text file (sample_text.txt) to the solution directory 6. You must implement at least one instance of pipe o command1 command2 You can use multiple | if you would like (e.g. command1 | command2 commands etc) 7. Create local variables as needed (at least one required). 8. Additional functions are not allowed. You must use the functions specified above. Please Note: The program should not exit after a user executes one of the options from the menu. Rather, it should display the menu again and allow the user to enter another option. To accomplish this, you simply need to create a while loop around the menu/case statements. Recording Output Completed script file TestFile.sh 1. Download sample_text.txt and put it into your lab_3 folder. 2. Create a new script file "TestFile.sh" inside your lab_3 folder. 3. You need to send sample_text.txt' as an argument/parameter while running this script. 4. Retrieve the argument name in the script file and check if the file (sample_text.txt) exists using an if-else structure. If the file does not exist, echo an error message to the user and exit the program (use exit). 5. If the file (sample_text.txt) exists, display a menu using case statements. Each menu item option should call a function (listed below). You must use the bash commands that were covered in class for all of the functionality within the program (sed, awk, grep, mv, etc). Available functions for the case statements are: o count_lines() - This function will count the number of lines in the file (using sed or awk or grep). Use echo to display the resultumber of lines to the screen (e.g. the number of lines in the file is..."). o count_words() - This function will search for all instances of the words: Lorem, model, Ipsum, will within the sample_text.txt (using sed or awk or grep). Use echo to display the lines from the file where the words are found. o add_text() - This function will prompt the user to enter a sentence and then the script should append the sentence to the end of the original text file sample_text.txt. Do not create a new text file during this process. The aforementioned sentence should be appended to the original sample_text.txt file. o copy_and_exit() - This function should create a new folder named solution within the same directory as the TestFile.sh script. Next, this function should use the cp command and copy the original text file (sample_text.txt) to the solution directory 6. You must implement at least one instance of pipe o command1 command2 You can use multiple | if you would like (e.g. command1 | command2 commands etc) 7. Create local variables as needed (at least one required). 8. Additional functions are not allowed. You must use the functions specified above. Please Note: The program should not exit after a user executes one of the options from the menu. Rather, it should display the menu again and allow the user to enter another option. To accomplish this, you simply need to create a while loop around the menu/case statements. Recording Output Completed script file TestFile.sh

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions