Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Linux Luwin keeps a record of everything that is spent or sold in his household.

ID: 3835632 • Letter: L

Question

Linux

Luwin keeps a record of everything that is spent or sold in his household. Records are stored in a file named record and here is a sample to show their format: [2 pts each, 12 total]

spent      $500       salting the roads because winter is coming spent    $9999 health insurance for Robb's wedding earned            $77         finely crafted snowmen spent $90         dog food for Robb's werewolf earned         $300 taxes from sworn house (Manderly) earned              $200       taxes from sworn house (Reed)

In each of the following, use one line to perform what is requested.

Display all lines with earnings.

Display only the amount of each expense. For example (above), you'd see 500, 9999, 90.

Display all lines related to a sworn house.

Replace Robb by DaBoss.

Count the number of lines related to the winter.

Count the number of lines that aren't related to a sworn house.

Explanation / Answer

Hi,

1) Display all lines with earnings : grep "earned" -i record

2) Display only the amount of each expense : cat record | awk '{print $1}'

3) display all lines related to sworn house : grep "sworn house" -i record

4) Replace Robb by DaBoss : sed -i 's/Robb/DaBoss/ig' record

5) Count the number of lines related to winter : grep winter -i record | wc -l

6) Count the number of lines that aren't related to a sworn house : grep "sworn house" -v record | wc -l

Thanks

Nikhil Jain

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote