Grep Tool Exercises

Published on February 5, 2025
Grep Tool Exercises

unfinished!

grep filters information, and is typically used on the commandline as one part of a chain of tools. Here's how grep might be used by testers.

If you've used graphical IDE tools that have a facility to search all files in a folder, there may be grep under the hood. Or, there may not – OS-based search typically indexes files and picks files from its index. grep doesn't have a search index (as far as I'm aware), but instead does pattern recognition on a stream – and one way to introduce a stream is to feed it files.

In this exercise, you’ll probably use command-line grep, and for some exercises you'll use it with other tools. There will be instructions, but the key concept is that if you see a command that looks like toolX | toolY, then toolX works first, and its output is connected to toolY's input. The | is called pipe, and (although it might be better if it was rotated 90 degrees ) it represents a connection.

If you're working with me, and I give you an environment, the files / streams will be there. If not, you'll need to download the files, and some exercises might not work for you (if they need streams, not files, and the streams aren't on).

This exercise is more fun in a group. If you’re in a group, please talk about what tool you’d use. Perhaps re-run the exercise with someone else’s tool of choice, or with someone else.

The solutions are below. The tool will do most of the work – give yourself kudos for spotting non-trivial things. Zero kudos if you look at the solutions before trying the exercises.

Exercises Group 1

Go to environment (not ready yet) or download the linked files (not ready yet).

Exercise 1.01

 file 1, file 2

Solution

Exercise 1.01 - short soln

details

monospaced
stuff


This page is a work in progress. I'm sure that a curious reader can easily find my notes to myself. «JL: perhaps, if the script finds any notes, it can insert this message?»