Question: Lab 4 Text Manipulation Complete the following exercises, making sure to follow the instructions carefully. Dont forget to put your name in the top right-hand
Lab 4 Text Manipulation
Complete the following exercises, making sure to follow the instructions carefully. Dont forget to put your name in the top right-hand corner of this document and rename the file to Lab4-Lastname, using your last name instead of lastname, before submitting via Blackboard.
Exercise 4-1
- Type cat testfile.001 and hit enter. Your cursor will blink, allowing you to type any text you wish. Type the following phrase, including a space at the end, before pressing Ctrl + D on your keyboard to end the command: We the people of the United States,
- Now type cat testfile.002 and hit enter. Once again, your cursor will blink, allowing you to type any text you wish. Type the following phrase, including a space at the end, before pressing Ctrl + D again: in order to form a more perfect union,
- Using the same method above, create testfile.003 with the following phrase, including a space at the end, before typing Ctrl + D: insure domestic tranquility, provide for the common defense, promote the general welfare, and secure the blessings of liberty to ourselves and our posterity,
- Using the same method above, create testfile.004 with the following phrase before typing Ctrl + D: do ordain and establish this Constitution for the United States of America.
- Type cat testfile.* > preamble and hit enter.
- Type cat preamble. What does the file contain? ________________________________________________________________________________________________________________________________________________
- Type wc preamble and hit enter. How many lines are in the file? ___________ How many words? _____________________ How many characters? _________________
- Type cat < preamble and hit enter. What happened, and why? ________________________________________________________________________________________________________________________________________________________________________________________________________________________
- Type ls /bin/user/news 2>> errorlog.txt and hit enter. What happened, and why? ________________________________________________________________________________________________________________________________________________________________________________________________________________________
- Issue the command history | cat >> lastname4-1, using your last name instead of lastname. Make sure to upload this file when submitting this assignment on BlackBoard.
- Once the file in step 10 is created, use the history -c command to clear your command history.
Exercise 4-2
Create a plaintext file with the following words typed out, in order and as specified:
Apple
Grape
Pear
Strawberry
Banana
Blueberry
Mango
Orange
Kiwi
Cherry
Create a single command, using pipes, that will display the file sorted in reverse order and excluding all lines that include the character p.
What is the command? _______________________________________________________
Run the command again, this time redirecting the output to a file called lastname4-2, using your last name instead of lastname. Make sure to upload this file when submitting this assignment on BlackBoard.
Exercise 4-3
Create a plaintext file with the following words typed out, in order and as specified:
Onion
Carrot
Asparagus
Broccoli
Cauliflower
Carrot
Lettuce
Lettuce
Corn
Celery
Create a single command using pipes that will display the first five lines of the file sorted in order with duplicates removed.
What is the command? _______________________________________________________
Run the command again, this time redirecting the output to a file called lastname4-3, using your last name instead of lastname. Make sure to upload this file when submitting this assignment on BlackBoard.
Exercise 4-4
Briefly explain what each of the following redirection characters mean.
> _______________________________________________
>> _______________________________________________
< _______________________________________________
2> _______________________________________________
2>> _______________________________________________
&> _______________________________________________
&>> _______________________________________________
Exercise 4-5
Provide the filename for each of the following:
Standard error ____________________________________
Standard input ____________________________________
Bit bucket ____________________________________
Standard output ____________________________________
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
