Read a file and find a line

Find a specific line in a text file.

Beginner

Lesson goal

Find a specific line in a text file.

How it works

cat prints the file. grep finds matching lines. The training grep implements literal matching and -i.

cat notes/first.txt
grep -i pwd notes/first.txt

Try it

Find the line mentioning pwd. Change the query and see what no matches looks like.

Check your understanding

What does empty output mean when the path is correct?

Next dayAll lessons
Search Linux DNA

DNA / GUIDANCE

Tux

Hi! Choose your goal and I’ll guide you to the right section.

Local guidance, no external AI or data collection.