Linux Today: Linux News On Internet Time.
Search Linux Today
Linux News Sections:  Developer -  High Performance -  Infrastructure -  IT Management -  Security -  Storage -
Linux Today Navigation
LT Home
Contribute
Contribute
Link to Us
Linux Jobs

Partner Sites
JustLinux.com
Linux Planet
PHPBuilder
Technology Jobs

Top White Papers

More on LinuxToday


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 extension:

ls *.jpg

"What actually happens here is that the shell expands the * before it passes the file list to ls. So that line is really equivalent to

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."

Complete Story

Related Stories: