CST 126 - Lab 7 - Delta College



CST 126 - Lab 7

(Chapter 6)

Name: Date:

Learning Objectives

1. To employ utilities in a script and redirect the output of a script to a file.

2. To get some practice using scripts to handle text analysis.

Lab Work

Part A:

1. Log on to the Unix server with your userid and password.

2. Open vi or pico and create a script called Information. Add the contents from the following table to the script: (Hint: use echo to add blank lines to your output and to write out the headings).

|Headings: |Utilities (command to execute) |

|Today’s date is: |date |

|The current users logged on to the system are: |who |

|My current startup directory is: |pwd |

|Today’s identification information is: |id |

|The processes running on my system are: |ps |

3. Add a header to your Information script file that contains a description of what the program does, your name, and date.

4. Save the file, set the file permissions to allow execution.

5. Execute the script and redirect the output to a file called DailyInfo

6. Print a copy of the Information script and the DailyInfo file. Staple these to this lab assignment.

Part B:

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: (Hint: Think about using the tr command, see pages 304-318)

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

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.

5. Print a copy of your TestScript script and your ScriptResult file. Attach them to this lab for turn-in.

Log out

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download