Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

need help with this filter assignment with unix Below you will find a copy of the poem Jabberwocky, which appears in Through the Looking Glass

image text in transcribed

need help with this filter assignment with unix

Below you will find a copy of the poem "Jabberwocky", which appears in Through the Looking Glass and What Alice Found There by Lewis Carroll. For each task, write down how you might accomplish it with grep, sed, or awk. If you do not think that a specific filter can perform a given task, then write N/A next to that filter. If you need more space (for a long-ish awk script, for example), feel free to attach another paper with the full set of commands (and a number to indicate the question). With sed, you can use either blocks of statements with flor multiple expressions with -e. With awk, you should write "command line" awk scripts. You may assume each word (and attached punctuation) is surrounded by a Is character and each line clearly ends with a In character. All of these filters use Extended Regular Expressions(sed requires -E flag but egrep and awk do not.) 'Twas brillig, and the slithy toves Did gyre and gimble in the wabe: All mimsy were the borogoves, And the mome raths outgrabe. 2) Print only the lines with Jabberwock" egrep: sed: awk: "Beware the Jabberwock, my son! The jaws that bite, the claws that catch! Beware the Jubjub bird, and shun The frumious Bandersnatch!" 3) Print only lines with 5 or less words egrep: sed: 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. awk: 4) Replace every "Jabberwock" with "Troll" egrep: And, as in uffish thought he stood, The Jabberwock, with eyes of flame, Came whiffling through the tulgey wood, And burbled as it came! sed: One, two! One, two! And through and through awk: The vorpal blade went snicker-snack! He left it dead, and with its head 5) Count the number of words in the text He went galumphing back. egrep: sed: "And hast thou slain the Jabberwock? Come to my arms, my beamish boy! Ofrabjous day! Callooh! Callay!" He choriled in his joy. awk: 'Twas brillig, and the slithy toves Did gyre and gimble in the wabe: All mimsy were the borogoves, And the mome raths outgrabe. 6 Print only the lines surrounded by quotation marks egrep: sed: Awk: 1) Print the first verse only egrep: 7) At every occurrence of '[Aa]nd' switch it with the following word egrep: sed: awk: sed: awk: Below you will find a copy of the poem "Jabberwocky", which appears in Through the Looking Glass and What Alice Found There by Lewis Carroll. For each task, write down how you might accomplish it with grep, sed, or awk. If you do not think that a specific filter can perform a given task, then write N/A next to that filter. If you need more space (for a long-ish awk script, for example), feel free to attach another paper with the full set of commands (and a number to indicate the question). With sed, you can use either blocks of statements with flor multiple expressions with -e. With awk, you should write "command line" awk scripts. You may assume each word (and attached punctuation) is surrounded by a Is character and each line clearly ends with a In character. All of these filters use Extended Regular Expressions(sed requires -E flag but egrep and awk do not.) 'Twas brillig, and the slithy toves Did gyre and gimble in the wabe: All mimsy were the borogoves, And the mome raths outgrabe. 2) Print only the lines with Jabberwock" egrep: sed: awk: "Beware the Jabberwock, my son! The jaws that bite, the claws that catch! Beware the Jubjub bird, and shun The frumious Bandersnatch!" 3) Print only lines with 5 or less words egrep: sed: 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. awk: 4) Replace every "Jabberwock" with "Troll" egrep: And, as in uffish thought he stood, The Jabberwock, with eyes of flame, Came whiffling through the tulgey wood, And burbled as it came! sed: One, two! One, two! And through and through awk: The vorpal blade went snicker-snack! He left it dead, and with its head 5) Count the number of words in the text He went galumphing back. egrep: sed: "And hast thou slain the Jabberwock? Come to my arms, my beamish boy! Ofrabjous day! Callooh! Callay!" He choriled in his joy. awk: 'Twas brillig, and the slithy toves Did gyre and gimble in the wabe: All mimsy were the borogoves, And the mome raths outgrabe. 6 Print only the lines surrounded by quotation marks egrep: sed: Awk: 1) Print the first verse only egrep: 7) At every occurrence of '[Aa]nd' switch it with the following word egrep: sed: awk: sed: awk

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

Database Concepts

Authors: David Kroenke, David J. Auer

3rd Edition

0131986252, 978-0131986251

More Books

Students also viewed these Databases questions