Bash Expansion

Wildcards #

Wildcards (aka Globbing or Globs) can be expanded by bash to match any of the following:

Wildcard Meaning
* Matches any characters
? Matches any single character
[characters] Matches any character that is a member of the set characters
[!characters] Matches any character that is not a member of the set characters
[:class:] Matches any character that is a member of the specified class
[:alnum:] matches any alphanumeric character
[:alpha:] Matches any alphabetic character
[:digit:] Matches any numeral
[:lower:] Matches any lowercase letter
[:upper:] Matches any uppercase letter

Arithmetic Expansion #

$((expression))

[me@linuxbox ~]$ echo $((2 + 2))
4 

Ex.

Operator Description
+ Addition
- Subtraction
* Multiplication
/ Division (integer only)
% Modulo (or remainder)
** Exponentiation

Pathname Expansion #

Stub

Brace Expansion #

[me@linuxbox ~]$ echo Front-{A,B,C}-Back
Front-A-Back Front-B-Back Front-C-Back
[me@linuxbox ~]$ echo Number_{1..5}
Number_1 Number_2 Number_3 Number_4 Number_5
[me@linuxbox ~]$ echo {Z..A}
Z Y X W V U T S R Q P O N M L K J I H G F E D C B A

Parameter Expansion #

[me@linuxbox ~]$ echo $USER
me

History Expansion #

Sequence Action
!! Repeat the last command
!number Repeat history list item number
!string Repeat history list item starting with string
!?string Repeat last history list item containing string