Filenames, Wildcards and Pathname Expansion: Difference between revisions

From RoggeWiki
Jump to navigation Jump to search
(New page: Basic Wildcards Wildcard Matches ? Any single character * Any string of character [''set''] Any character in ''set'' [!''set''] Any character not in ''set'')
 
 
(14 intermediate revisions by the same user not shown)
Line 1: Line 1:
Basic Wildcards
==Regular Expressions==
 
What is an expression? An expression doesn't literally mean what it says. An expression, even in computer technology, is not something to be interpreted literally. It is something that needs to be evaluated. An expression describes a result. An expression tells the computer how to produce a result.
 
==Basic Wildcards==


Wildcard Matches
Wildcard Matches
Line 6: Line 10:
[''set''] Any character in ''set''
[''set''] Any character in ''set''
[!''set''] Any character not in ''set''
[!''set''] Any character not in ''set''
==Globbing==
Bash itself cannot recognize Regular Expressions. Scripts, commands and utilities, such as sed and awk, interpret Regular Expressions.
Bash does carry out filename expansion, a process known as "globbing", but this does not use the standard RE set. Instead, globbing recognizes and expands wildcards. Globbing interprets the standard wildcard characters, * and ?, character lists in square brackets, and certain other special characters (such as ^ for negating the sense of a match). There are some important limitations on wildcard characters in globbing, however. Strings containing * will not match filenames that start with a dot, as, for example, .bashrc. [1] Likewise, the ? has a different meaning in globbing than as part of an RE. Filename expansion can match dotfiles, but only if the pattern explicitly includes the dot.
[[Category:Unix]]

Latest revision as of 13:29, 4 April 2014

Regular Expressions

What is an expression? An expression doesn't literally mean what it says. An expression, even in computer technology, is not something to be interpreted literally. It is something that needs to be evaluated. An expression describes a result. An expression tells the computer how to produce a result.

Basic Wildcards

Wildcard Matches ? Any single character

  • Any string of character

[set] Any character in set [!set] Any character not in set

Globbing

Bash itself cannot recognize Regular Expressions. Scripts, commands and utilities, such as sed and awk, interpret Regular Expressions.

Bash does carry out filename expansion, a process known as "globbing", but this does not use the standard RE set. Instead, globbing recognizes and expands wildcards. Globbing interprets the standard wildcard characters, * and ?, character lists in square brackets, and certain other special characters (such as ^ for negating the sense of a match). There are some important limitations on wildcard characters in globbing, however. Strings containing * will not match filenames that start with a dot, as, for example, .bashrc. [1] Likewise, the ? has a different meaning in globbing than as part of an RE. Filename expansion can match dotfiles, but only if the pattern explicitly includes the dot.