Finding Things on Linux and Understanding Regular Expressions
Sep 14, 2009, 19:34 (0 Talkback[s])
(Other stories by Juliet Kemp)
"There's some basic regexp-type provision built into the shell:
the most basic example of this is the * wildcard. This example will
list every file in the current directory which has a .jpg
"What actually happens here is that the shell expands the *
before it passes the file list to ls. So that line is really
ls file1.jpg file2.jpg ...
"In contrast, this command-line will produce the same output,
but using grep with full regexp syntax (see the next section for
more on grep):
ls | grep '.*.jpg'
"This runs ls on the current directory (so listing all files),
then passes the output through grep, which uses 'proper' regexps,
rather than the shell built-in."