Bash Patterns

From NovaOrdis Knowledge Base
Jump to navigation Jump to search

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.

/

/ (slash)

~

~ (tilda)

Non-Special Characters

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

\ # forward slash