Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2.1 Stage 1 1. Create a directory /UnixCourse/scriptAsst. 2. Within that directory, create a shell script, textcounteri.sh, that takes a single command line parameter, a

image text in transcribed

image text in transcribed

2.1 Stage 1 1. Create a directory /UnixCourse/scriptAsst. 2. Within that directory, create a shell script, textcounteri.sh, that takes a single command line parameter, a file path (might be relative or absolute). The script should examine that file and print two lines of the form n words m sentences (replacing n and m by the correct numbers, of course). o For our purposes, a "word" is any consecutive string of non-whitespace characters containing at least one alphabetic (upper or lower case) character. (A "whitespace" character would be a blank or line ending.) There may be non-alphabetic characters mixed in as well. So Hello!" and "abc123" are words, but "42 and"!?" are not. o A "sentence" is any sequence of zero or more words ending with a period, question mark, or exclamation mark. You can count sentences by simply counting the number of periods, question marks, and e n marks in the file For example, from previous assignments, you should have files jabberwocky1.txt and mtsw10.txt. Applying this script to these files should result in the following output $ ./textCounter1.sh ../emacsAsst/mtswe10.txt 8920 words 655 sentences $ ./textCounter1.sh/emacsxAsst/jabberwocky1.txt 170 words 17 sentences A hint to get you started. o The command sed s/ /g" myFile.txt would replace all strings of 1 or more blanks by a newline ( ) character. In effect, this puts each word on a separate line. Try this out with a few files and look at the output carefully. Then think about how you could combine that idea with some other commands you have used this semester to get a count of the words. 3. When you believe that you have your script working, run

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

Data And Databases

Authors: Jeff Mapua

1st Edition

1978502257, 978-1978502253

More Books

Students also viewed these Databases questions