Regular expressions are patterns in which certain characters or character combinations are interpreted
specially when being matched against a data string. grep, sed and awk treat patterns as regular
expressions. For example, regular expressions allow the use of wildcards in search strings (patterns).
Note that regular expressions are different from the shell's wildcard system.
Regular expressions include:
^$\<\>..*c*\cc?[agkAGK][0-9a-f][^string]Examples of patterns
^TheThe\<[A-Z]embar?ass*embaras, or any other spelling
with one or more r's or more s's; also
unembaras, embarased etc.x.*yx followed by y with
any or no characters betweenCertain characters are interpreted with a special meaning by the shell. Often they can be interpreted differently depending on the context.
Examples
*ls p* would list all the
filenames in the current directory beginning with
the letter p.?ls jun??.dat would list all the files
beginning with the characters jun, ending
with .dat and with any 2 characters in between.[rm prog[2-4p-r].c could delete, if the files
exist, prog2.c, prog3.c,
prog4.c, progp.c,
progq.c, progr.c.~ls ~mary would list the
contents of the home directory of user mary,
whose full pathname could be /u0/xhul/mary.{rm {prog1,testing,yesterday}.c would remove
the files prog1.c, testing.c and
yesterday.c. Note, in the last example there
should be no spaces separating the comma separated
list of files.$echo $PRINTER would display the
current value of the environment variable PRINTER!!3 would reissue the command numbered 3 in
your command history (if available).&& can be used to run a job in the
background, for example f77 program.f &,
would compile and link the FORTRAN program
program.f in the
background. && is the logical operator
for AND in a programming context.|ls -al |more,
would send the directory listing output of ls
as the input to the scroll command more.<maple < algebra, sends the file
algebra as the input to the program
maple.>ls > dir_list sends the output of
ls to a file called dir_list.;ls -l | more; quota would list files a screenful
at a time and then list your current quota usage.(if ($string=='Jane') then\\. For example, to display the string
<*Hello*> would require
echo\<\*Hello\*\>