We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Grep

You might be used to nice graphical interfaces that allow you to search for text in files, usually with Ctrl+F or Cmd+F. But what about when you're working in a terminal?

As it turns out, once you're used to it, searching for text in files in a CLI can be much faster than using a GUI.

The grep Command

The grep command allows you to search for text in files. It has a ton of capability, and we'll only be scratching the surface of its true power.

Basic Usage

The most basic use for grep is to search for a string in a file. For example, if we wanted to search for the word "hello" in the file words.txt, we could run:

grep "hello" words.txt

This will print out every line in words.txt that contains the word hello. It's a case-sensitive search, so it will only match hello, not Hello or HELLO.

Assignment

Applications often write their logs to files on disk. These logs can contain useful information about what the application is doing, and can also be used to debug problems. As a security auditor, you need to dig through these logs to find any evidence of suspicious activity.

Use the grep command to find any lines with the text "CRITICAL" (all caps) in the worldbanc/private/logs/2024-01-10.log file.

Submit the shell checks.