Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Linux 1. Create and save a new text file called Gasoline that consists of the fo

ID: 3775977 • Letter: L

Question

Linux 1. Create and save a new text file called Gasoline that consists of the following content: Gas prices stayed about the same the past two weeks, continuing an unusual 12 week trend of steadily increasing prices followed by prices relaxing. The average price for gas nationwide, including all grades and taxes, was about $2.97 a gallon on Friday, according to a survey of 8,000 stations released Sunday. That was up .06 cents per gallon from Jan 18. Prices have been holding steady since early January, when a gallon of gas cost about $3.00. 2. Create an analysis script called TestScript that completes the following tasks for the Gasoline file:

a. Remove punctuation

b. Make all characters lowercase

c. Put each word on a single line

d. Remove blank lines

e. Sort the text to put all lines containing the same word on adjacent lines. Hint: Use | sort | uniq -c for this part.

f. Remove duplicate words from the text

g. List most-used words in the file first

h. Send the output of this script to a file named ScriptResult

3. Save the script. Make it executable. Run the script.

4. Open the ScriptResult file and verify that the contents match what was asked for in the TestScript script.

Explanation / Answer

cat Gasoline | tr ' ' ' ' | tr '[:upper:]' '[:lower:]' | tr -d '[:punct:]' | grep -v '[^a-z]' | sort | uniq -c | sort -rn | head

------------------------------------------------------------------------------------------------------------------------------------------------------------------

explaination:

I took it one tr command at a time, then rearranged them in a different order of operation.

first I remove the punctuation putting a space in place of it to get that 20word to 20 word, so I an put each one on a new line each, then change the caps to lower case. then put it into another file, then send it to sed to print out on the screen, I have no idea what that sed command actually does, I don't play with sed, nor tr ... I only learn what I have to as I go to get my scripts to work to do what I actually need them to do. more real world applications in my experience.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------

3. Place all command in a file and using an interpreter (in your case bash) to execute the commands in the file. This also has multiple options:

a. Simplest case is to put the commands in the file, we will call script.sh, and execute thusly:

Code:

b. Again place the commands in the file and at the top of the file you identify which interpreter (this should have been explained already in your class) to use: (you will also need to make the file executable)

Code:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote