~/ learn/ comp-325/ cards/ A glob is not a regular expression
1 of 9

The side-by-side that makes the difference visible

The side-by-side that makes the difference visible

Answer

ls *.c ls | grep '*.c' ls | grep '\.c$'

Line 1 lists the four C files — the shell expanded the glob. Line 2 lists nothing: with no item in front of it the star is taken literally, so grep hunts for a real asterisk. Line 3 is the regex that was meant all along.

Sarwar & Koretsky 3e ch4 §4.5.2 versus ch7 §7.5

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/551b4315-f78b-459d-a4f7-9367103ac9fd/flashcard utf-8 LF