Bash Patterns: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 34: Line 34:


  \ # forward slash
  \ # forward slash
. # dot - does NOT match any character, it just matches a dot

Revision as of 00:03, 19 September 2019

External

Internal

Metacharacters

The following characters have a special meaning when a bash pattern is evaluated, and they need to be escaped to be matched literally:

*

* (star) matches any string, including the null string. When the globstar shell option is enabled, and ‘*’ is used in a filename expansion context, two adjacent ‘*’s used as a single pattern will match all files and zero or more directories and subdirectories. If followed by a ‘/’, two adjacent ‘*’s will match only directories and subdirectories.

?

? (question mark) matches a single character. The dot ('.') is not a metacharacter.

/

/ (slash)

~

~ (tilda)

Non-Special Characters

These characters do not need to be escaped in bash patterns to match:

\ # forward slash
. # dot - does NOT match any character, it just matches a dot