Using wildcards and regexes

As we saw in the previous section, there was this new concept of recursive functions and the introduction of wildcards. This section will extend upon those same fundamental primitives to create more advanced searches using regexes and globbing.

It will also extend them with a number of built-in Bash features, and some one-liners (nifty tricks) to enhance our searches. In short:

  • A wildcard can be: *, {*.ooh,*.ahh}, /home/*/path/*.txt, [0-10], [!a], ?, [a,p] m
  • A regex can be: $, ^, *, [], [!], | (be careful to escape this)

Globbing basically refers to a far more computer-eccentric term, which can be simply described in layman terms as extended pattern matching. Wildcards are the symbols used to describe patterns, ...

Get Bash Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.