The University of Arizona.
Eller College of Management, The University of Arizona in Tucson, Arizona.
Eller IT.
Explore EllerAcademic ProgramsExecutive EducationFaculty & StaffResearch & InnovationNews & Events

UNIX Shells

UNIX Shells
Shell Metacharacters
Important Files in your Home Directory
Built-in Korn and Bourne Shell Variables
Built-in C Shell Variables
Rules for Forming Regular Expressions


UNIX Shells

Bourne Shell sh $
C Shell csh %
Korn Shell ksh

Shell Metacharacters

Metacharacter
Description
Input/Output
 
< Redirects input
> Redirects output to a specified file.
<< Redirects input and specifies that the shell should read input up to a specified line.
>> Redirects output and specifies that the shell should add output to the end of a file.
2> Redirects diagnostic output to a specified file. (Bourne shell only)
>! Redirects output and specifies that if the noclobber variable is set (prevents the overwriting of files), it should be ignored so that the files can be overwritten. (C shell only)
>& Redirects both diagnostic and standard output and appends them to a file (C and Korn shells only)
>>& Redirects both diagnostic and standard output to the end of an existing file (C shell only)
   
Expansion and subtitution
 
$ Specifies variable substitution. (C shell only)
! Specifies history substitution (C shell only)
: Preceeds substitution modifiers (C shell only)
^ Used in special kinds of history substitution. (C shell only)
' Specifies command substitution (C shell only)
${...} Specify variable substitution. (Bourne and Korn shells only)
% Specify job number substitution. (Korn shell only)
...' Specify command output substitution. (Korn shell only)
'...' Specifies command output substitution. (Bourne shell only)
   
Syntactic
 
; Separates commands that should be executed sequentially.
| Separates commands that are part of a pipeline.
&& Runs the next command if the current command succeeds
|| Runs the next command if the current command fails
;; Separates elements of a case construct. (Bourne and Korn Shells only)
& Runs a command in the background.
( ) Groups commands to run as a separate process in a subshell.
{ } Groups commands without creating a subshell. (Korn shell only)
   
Filename
 
/ Separates the parts of a file's path name.
? Matches any single character except a leading dot (.).
* Matches any sequence of characters except a leading dot (.).
[ ] Matches any of the enclosed characters.
~ Specifies home directory when used at the beginning of file names. (C and Korn shell only)
   
Quotation
 
\ Specifies that the following character should be interpreted litterally; that is, without special meaning to the shell.
'...' Specifies that any of the enclosed characters (except for ' in Korn and C shells, and &' in Bourne shell) should be interpreted literally; that is, without their special meaning to the shell.
"..." Provides a special form of quoting. Specifies that the $, `(grave accent), and \ characters keep their special meaning, while all other enclosed characters are interpreted literally; that is, without their special meaning to the shell.

Important Files in your Home Directory

File Name
Purpose of the File
.cshrc Defines your C shell environment with the .login file. (Read each time you start a new shell)
default.DECterm Stores customization information for DECterms.
.kshrc Defines your Korn shell environment with the .profile file. (Read each time you start a new shell)
.login Defines your C shell environment. (Read only when you log into the system)
.mh_profile Defines the environment for MH.
.mailrc Defines the environment for mailx (Mail) and mail (binmail).
.mwmrc Defines workspace menus and key bindings.
.profile Defines your Korn and Bourne shell environments. (Read only when you log into the system)
.X11Startup Controls which applications are invoked when you start a workstation session.
.XDefaults Records Session Manager customizations.

Built-in Korn and Bourne Shell Variables

Variable
Description
HOME Specifies the name of your login directory; the directory that is the current directory when you log in.
PATH Specifies the directories through which your system searches to find and execute commands.
CDPATH Specifies the directories that the cd command searches to find the specified argument to cd.
MAIL Specifies the path name of the file where your mail is deposited.
MAILCHECK Specifies in seconds how often the shell checks for mail (600 seconds is the default.)
SHELL Specifies your default shell.
PS1 Specifies the default Bourne shell prompt. The default value is $ (dollar sign).
PS2 Specifies the secondary prompt string; the string that the shell displays when it requires more input after you enter a command line.
HISTFILE Specifies the path name of the file that is used to store the command history. (Korn shell only)
EDITOR Specifies the default editor for command line editing at the shell prompt and for filename completion. (Korn shell only)
FCEDIT Specifies the default editor for the fc command. (Kornshell only)
HISTSIZE Specifies the number of previously entered commands that are accessible by this shell. (Korn shell only)

Built-in C Shell Variables

Variable
Description
argv Specifies the name of your login directory; the directory that is the current directory when you log in.
autologout Specifies the directories through which your system searches to find and execute commands.
cwd Specifies the directories that the cd command searches to find the specified argument to cd.
home Specifies the path name of the file where your mail is deposited.
ignoreeof Specifies in seconds how often the shell checks for mail (600 seconds is the default.)
cdpath Specifies your default shell.
noclobber Specifies the default Bourne shell prompt. The default value is $ (dollar sign).
notify Specifies the secondary prompt string; the string that the shell displays when it requires more input after you enter a command line.
path Specifies the path name of the file that is used to store the command history. (Korn shell only)
prompt Specifies the default editor for command line editing at the shell prompt and for filename completion. (Korn shell only)
shell Specifies the default editor for the fc command. (Korn shell only)
status Specifies the number of previously entered commands that are accessible by this shell. (Korn shell only)

Rules For Forming Regular Expressions

Expression
Rule

0-9, A-Z, a-z,
most punctuation

Matches itself.
. Matches any single character.
\char Matches the character following the backslash regardless of whether the character is a metacharacter.
* Matches any number of occurrences of the preceding expression, including none.
[ chars ] Matches any one of the characters within the brackets. Ranges of characters can be abbreviated.
^ Matches the beginning of a line when used at the beginning of an expression. When used as the first character inside brackets, excludes the bracketed characters from being matched. Otherwise, matches itself.
expr expr ... Forms a compound expression that matches any string which matches the first simple expression, then the second, and so on.
.profile Defines your Korn and Bourne shell environments. (Read only when you log into the system)

 

  

 
   
Resources:
 
 
  
Eller IT Orientation Packet
Blackboard How-To Helpers
Extended University
UA Library Workshops
Multimedia Learning Lab Computer Workshops
Learning Technology Center   
 
 
  
Eller College Home   |   UA   |   Disclaimer   |   Privacy   |   Site Index

Eller College of Management   |   The University of Arizona
1130 E. Helen Street   |   P.O. Box 210108   |   Tucson, AZ 85721-0108   |   520.621.2165
  
© Copyright 2008 The University of Arizona. All rights reserved.
  

The University of Arizona : Arizona's First University.