Bash Patterns: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 13: Line 13:
The following characters have a special meaning when a bash pattern is evaluated, and they need to be escaped to be matched literally:
The following characters have a special meaning when a bash pattern is evaluated, and they need to be escaped to be matched literally:


/ # slash
==*==
~ # tilda
 
* # star
* (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=
=Non-Special Characters=

Revision as of 23:56, 18 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.

/

/ (slash)

~

~ (tilda)

Non-Special Characters

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

\ # forward slash