1. Create a file called poem.txt with the following text in it: Ro...

  1. Home
  2. Homework Library
  3. Computer Science
  4. Linux
  5. 1. Create a file called poem.txt with the following text in it: Ro...


1. Create a file called poem.txt with the following text in it:
Roses are red
Violets are blue;
Don’t you hate it
When stuff doesn’t rhyme?

Now create a file called breakit. Enter the following script in it:

#! /bin/bash
while read input
for word in $input
echo $word

Execute the script with poem.txt as input:

./breakit < poem.txt

Compare the results of your breakit script with the results of this command:

tr ‘ ‘ ‘\n’ < poem.txt

The first part of that is tr SPACE apostrophe SPACE apostrophe SPACE, and those are apostrophes around \n.

Both commands produce similar output. Are they doing the same thing? Explain.

2. On the class server, try these two commands (use the poem.txt file you created for question #1 as your text file here):

this command expr `cat poem.txt | wc –c` / `cat poem.txt | wc –l` evaluates a
this command expr `wc –c poem.txt` / `wc –l poem.txt` doesn't work

Why does one work and the other doesn’t? What are these commands both doing? Explain each in detail.

3. On the class server, set the following variable:
Now check its value:
echo $sunset

Launch a new bash subshell by typing in bash and hitting enter.
Once you’ve launched the subshell, try this command again:

echo $sunset
What happened? Why? What would you need to do to make this work? Show the command it would take to make echo $sunset work in both cases.

4. On the class server, use this command to set up an alias:
alias ghist=‘history | grep’
Once it’s set, use it with various commands that you know, like:
ghist cd
What kind of output do you get when trying this with different commands? What is the ghist alias doing when combined with different commands? Explain.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

    By purchasing this solution you'll be able to access the following files:

    for this solution

    PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

    Find A Tutor

    View available Linux Tutors

    Get College Homework Help.

    Are you sure you don't want to upload any files?

    Fast tutor response requires as much info as possible.

    Upload a file
    Continue without uploading

    We couldn't find that subject.
    Please select the best match from the list below.

    We'll send you an email right away. If it's not in your inbox, check your spam folder.

    • 1
    • 2
    • 3
    Live Chats