Finding Things on Linux and Understanding Regular Expressions | Linux Today

Finding Things on Linux and Understanding Regular Expressions

Written By
JK
Juliet Kemp
Sep 14, 2009

“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

JK

Juliet Kemp

Linux Today Logo

LinuxToday is a trusted, contributor-driven news resource supporting all types of Linux users. Our thriving international community engages with us through social media and frequent content contributions aimed at solving problems ranging from personal computing to enterprise-level IT operations. LinuxToday serves as a home for a community that struggles to find comparable information elsewhere on the web.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.