Question

Using the Jabberwocky poem: 'Twas brillig, and the slithy toves Did gyre and gimble in the...

Using the Jabberwocky poem:

'Twas brillig, and the slithy toves Did gyre and gimble in the wabe; All mimsy were the borogoves, And the mome raths outgrabe. "Beware the Jabberwock, my son! The jaws that bite, the claws that catch! Beware the Jubjub bird, and shun The frumious Bandersnatch!" He took his vorpal sword in hand: Long time the manxome foe he sought-- So rested he by the Tumtum tree, And stood awhile in thought. And, as in uffish thought he stood, The Jabberwock, with eyes of flame, Came whiffling through the tulgey wood, And burbled as it came! One two! One two! And through and through The vorpal blade went snicker-snack! He left it dead, and with its head He went galumphing back. "And hast thou slain the Jabberwock? Come to my arms, my beamish boy! O frabjous day! Callooh! Callay!" He chortled in his joy. 'Twas brillig, and the slithy toves Did gyre and gimble in the wabe; All mimsy were the borogoves, And the mome raths outgrabe.

Answer the following questions:

Question 1: Find a regular expression that will allow you to grep for all lines containing words that start with "H" and end with "d".

Question 2: Find a regular expression that will match all lines containing a capital "T", but not if capital "T" is the first character in the line.

Question 3: Using sed, replace "'Twas" with "It certainly was" (notice the apostrophe before the ‘T’).

Question 4: Using sed, replace all occurrences of "the" or "The" with "a" or "A" (preserving the capitalization of the original).

Question 5: Find all of the punctuation marks used in the poem, and give a count of the number of occurrences of each.

Homework Answers

Answer #1

1)  grep '^H.*d$>' poem.txt

we use ^ for specifying starting characters and $ for ending characters

.* is used for specifying the word may contain any number of character inbetween H and d

2) grep '^[^T][T]' poem.txt

[^T] specifies that all matches except T.

^[^T] specifies that all matches except T as a start

[T] specifies all matches contains T

3)  sed "s:'Twas/It certainly was:g" poem.txt

sed "s/old-text/new-text/g" input.txt is the syntax

Here we used : instead of / to include space in between the new text 'It certain was'

4)  sed 's:The/A:g; s:the/a:g ' poem.txt

To sed multiple pattern in a single call, we use ; to seperate two replacements.

5) grep -o '[[:punct:]]' poem.txt | sort | uniq -c

[:punct:] specifies all punctuation character

[[:punct:]] means all that matches punctuation characters

uniq -c is for counting the number of occurences

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Chapter 8: Searching, Extracting, and Archiving Data Exercise 8.a: Using grep, find, and regular expressions (Objective...
Chapter 8: Searching, Extracting, and Archiving Data Exercise 8.a: Using grep, find, and regular expressions (Objective 3.2) Linux Distribution: Fedora (non-root user & password needed) Desktop Environment: GNOME 3 1.   If you have not already done so, boot up your computer (or virtual machine) to start the Fedora Linux distribution. 2.   When the machine has booted up, access the tty2 virtual terminal by pressing Ctrl+Alt+F2. 3.   Log on to a regular user’s account by typing in the username at the...
CH 23 Case Study on Neurocognitive Disorders Jack and Margaret have had the same family physician...
CH 23 Case Study on Neurocognitive Disorders Jack and Margaret have had the same family physician through the last 22 years of their marriage, ever since they moved to Santa Fe, where Jack is an artist. “We came here so Jack could pursue his painting,” Margaret says. “He’s a wonderful artist, and for years he was a wonderful dad. When our youngest child finally left the nest, we decided it was time for an adventure. We moved to Santa Fe,...
To Make a Cup of Coffee, It Takes More Than a Village A journey of thanks...
To Make a Cup of Coffee, It Takes More Than a Village A journey of thanks for a simple daily pleasure reveals the miracle of a globalized economy. I recently had the opportunity to gaze at one of the most mind-boggling accomplishments in history. This marvel is the result of thousands of human beings collaborating across dozens of countries. It required the combined labor of artists, biologists, politicians, mechanics, miners and goatherds. It took airplanes, boats, trucks, motorcycles, vans, pallets...
CASE Wyatt Earp - The Buffalo Hunter F. Robert Jacobs, Indiana University The legend of Wyatt...
CASE Wyatt Earp - The Buffalo Hunter F. Robert Jacobs, Indiana University The legend of Wyatt Earp lives on largely based on his exploits as a gunfighter and Marshall of the frontier West in the 1880s. The classic tales of the shootout at the O.K. Corral in Tombstone or his sawed-off shotgun duel with Curly Bill are possibly the most celebrated gunfights of frontier history and cannot fail to stir the reader's imagination. Wyatt lived to be over 80 years...
Question 1 Case A Marty Ofori worked for a card company specializing in invitations and announcements....
Question 1 Case A Marty Ofori worked for a card company specializing in invitations and announcements. Every day for 25 years, he went to an office, sat at a desk, and took orders over the phone. He hated it. He was bored out of his mind. He didn’t know what to do. So he began skimming the business opportunities section of The Mirror. He wasn’t sure what he was looking for. At almost 50 years of age, he had few...
Question(C++). Please write a C++ code, it will generate a conversation between Hans and Beatrice by...
Question(C++). Please write a C++ code, it will generate a conversation between Hans and Beatrice by randomly selecting phrases and sentences from files, then altering them before output The code will start the conversation between Hans and Beatrice by having Hans say "hello" (it's him who makes the call). This is to be followed alternately by Beatrice and then Hans saying something. Each thing they say will be chosen at random from their respective files, HansSayings.dat and BeatriceSayings.dat. But before...
The Nataraj Metal Products Company (hereinafter referred to as the Nataraj), has it manufacturing plant at...
The Nataraj Metal Products Company (hereinafter referred to as the Nataraj), has it manufacturing plant at Arani and employs about 500 workers. It produces a variety of metal products such as brass knobs, steel frames, collapsible iron gates, chromium handles and so on. Orders for these are placed by building contractors in and around Madras but the volume of orders fluctuates, with the rainy season being the slowest period. The company is reputed for quality products delivered on time and...
Actually a HISTORY question: what tactics does Einhard use to portray Charlemagne in "Life of Charlemagne"...
Actually a HISTORY question: what tactics does Einhard use to portray Charlemagne in "Life of Charlemagne" and what tactics does Procipius use to describe Justinian in a positive light in the "Nika Riots"? Ive posted both excerpts. "Life of Charlemagne" Charles the Great, (Charlemagne in French) reigned 768-814 as king of the Franks and the most important ruler of the Carolingian Dynasty, conquering lands in what is now Germany, France, Spain, and Italy. On Christmas Day 800 C.E., Pope Leo...
Write a Python 3 program called “parse.py” using the template for a Python program that we...
Write a Python 3 program called “parse.py” using the template for a Python program that we covered in this module. Note: Use this mod7.txt input file. Name your output file “output.txt”. Build your program using a main function and at least one other function. Give your input and output file names as command line arguments. Your program will read the input file, and will output the following information to the output file as well as printing it to the screen:...
In narrative essay format, I want you to address a business/organization case study using multiple concepts...
In narrative essay format, I want you to address a business/organization case study using multiple concepts from class. The case question and case text begin on page 5 of this document. You need to demonstrate their best understanding of management and organizational behavior theory, and the application of those ideas to improve the understanding of various issues. You need to clearly identify at least 3 distinct, substantive issues. For each issue you need to 1), identify evidence from the case...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT