Unix Tools for Behavioral Research
The following characters all have special uses or meanings in UNIX (some have special names)
Unix offers powerful 'wildcard' operations which allow one to type in only the unique portion of a filename and then substitute a "multiple character wildcard" '*' for the rest.
If only a single character needs to be substituted for then a '?' is used.
example: ls AX*
lists all files starting with AX (including AX)
example: ls AX?
lists all three-letter file names starting with AX (but won't list a file called AX).
[ ] is used to define a set to allow the substitution of a single character from a class of alpha-numeric characters.
Any string of characters within [ ] are treated as the class of characters to substitute for.
Unix recognizes continuous series of letters or numbers so that [1-9] or [a-z] represent the digits one through nine and all lowercase letters.
The series [a-zA-Z] represents all letters. However, because of the way characters are generated [a-Z] doesn't represent all letters. Instead it represents the set "a, -, Z".
If two sets are placed side by side then there is substitution for two characters meeting the conditions of both sets. (eg [a-z][A-Z] will substitute for any lowercase letter followed by any uppercase letter).
example: ls [AX]? (lists all two letter file names starting with either and A or an X)
example: ls [mn]* (Lists all files starting with either m or n followed by anything else)
example: ls [AX]?[mn] (lists all three letter filenames starting with either an A or an X followed by any single character and ending with and m or an n.
example: ls q_[abc1-4]?xy* (Lists all files starting with q_ followed by an a, b, c, or a digit 1-4, followed by any single character, followed by xy and then anything.
(First of all DON'T), but there is a way of telling UNIX that you want to abort the special nature of these characters.
The '\' character says that the single character that follows is to be treated as a literal. Thus '\*' loses its special meaning and just becomes a splat.
This "\ " followed by a single character is refered to as an escape sequence.
When in doubt you can always escape a character with a backslash. Note this is not a '/', but a '\'.
What are these other special characters used for?
Not all of the special characters are described here; just the ones you need to regularly know.
# Comments - in a shell script (program) everything after the # is ignored
^ means START(used to indicate the start of a line)
$ means END
example: ls | grep X$ (find all files ending with X)
$ also indicates1
! means NOT
" is weak quote
' is strong quote
! This isn't an exclamation point, it's a "bang". Return
^ Nope, this isn't a carat, it's a "hat". Return
* You may have thought this is an asterisk, but it's not. It's a "splat". Return
. This is a "dot", not a period. Return
| This is a "pipe" not whatever it is really called (a semi-flat?). Return
/ When the top tips to the right it's a "slash". Return
\ When the top tips to the left it's a "backslash" Return
Alpha-numeric means the set of all typable characters (a-z, A-Z, 0-9, punctuation). Return