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

Linux using grep and sed answer the following questions Luwin keeps a record of

ID: 3837930 • Letter: L

Question

Linux using grep and sed answer the following questions

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

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

Display all lines with earnings    - grep -i "earned" filename

Display only the amount of each expense - cat test.txt | grep -i spent | awk '{print $2;}'

Display all lines related to a sworn house - grep -i 'sworn house' filename

Replace Robb by DaBoss - sed 's/Robb/DaBoss/g' filename

Count the number of lines related to the winter - grep -c "winter" filename

Count the number of lines that aren't related to a sworn house - grep -v "sworn house" filename

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