Trace filename expansion before content matching

An audit directory contains exactly the seven regular files below. Each file contains exactly the two lines shown, with no leading or trailing spaces.


Filename

First line

Second line

run1.log

OK. 07

FAIL. 18

run12.log

OKx 42

OK. 8

run2a.log

OK. 31

OK. 64

run3.log

OK. 09 extra

OK. 90

runA.log

OK. 55

FAIL. 00

.run4.log

OK. 23

FAIL. 00

run5.log.bak

OK. 44

FAIL. 00


From this directory, you run:


Shell
grep -lE '^OK[.] [0-9]{2}$' run[0-9]*.log


Use Bash's default filename-matching settings in the C locale. The -E option enables extended regular expressions. The -l option prints each searched filename once if that file contains at least one matching line; it does not print matching lines. Assume all files are readable.


Find both quantities as exact integers: the number of files selected for searching and the number of filenames printed.

Your answers

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Regular Expressions and Wild Cards Questions: