~/ 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/d61a2de9-fa8c-4104-b02a-d546f34d16d9/flashcard utf-8 LF