>_ IzzyLab

Hands-on task

This task is step 2 of the course “First steps with text”

Find the reviews about delivery

easy~4 min

/root/data/feedback.txt holds customer reviews, one per line. A manager asks you to collect every review that mentions the word "delivery". Customers write it however they like: "Delivery", "delivery", "DELIVERY".

Save to /root/delivery.txt every line with the word "delivery" in any letter case — unchanged and in the same order as in the file.

What you'll practise:
  • grep
  • grep -i
  • letter case

Topic breakdown

grep reads a file and prints only the lines where the given text was found. It skips the rest, and the order is kept.

Letter case matters to grep: "Linux", "linux" and "LINUX" are three different texts. The -i flag (ignore case) turns that off:

grep root /etc/group       # only "root" in lowercase
grep -i ROOT /etc/group    # root, Root, ROOT — every variant

The flag goes before the search text. If the text has spaces, put it in quotes.

What's checked

  1. File /root/delivery.txt created
  2. delivery.txt holds only reviews about delivery
  3. All reviews about delivery are there, in order and unchanged

What it looks like