Filenames, Wildcards and Pathname Expansion: Difference between revisions

From RoggeWiki
Jump to navigation Jump to search
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Regular Expressions==
==Regular Expressions==


What is an expression? An expression doesn't literally mean what it says.
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.
An expression, even in computer technology, is not somethng 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==
==Basic Wildcards==
Line 12: Line 11:
[!''set''] Any character not in ''set''
[!''set''] Any character not in ''set''


<span class="warning">password too short</span>
==Globbing==


aap
Bash itself cannot recognize Regular Expressions. Scripts, commands and utilities, such as sed and awk, interpret Regular Expressions.
<pre>
?  a
*  a
[set]
[!set]
</pre>
aap
{| table rules="cols"
|-
! header 1
! header 2
! header 3
|- table rules="rows"
| table rules="rows" row 1, cell 1
| row 1, cell 2
| row 1, cell 3
|-
| row 2, cell 1
| row 2, cell 2
| row 2, cell 3
|}


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.




{| class="wikitable" style="margin: 1em auto 1em auto"
 
|+ '''Cells left-aligned, table centered'''
[[Category:Unix]]
! Duis || aute || irure
|-
| dolor  || in reprehenderit || in voluptate velit
|-
| esse cillum dolore || eu fugiat nulla || pariatur.
|}

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.