



























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Notes; Class: Programming Unix; Subject: COMP Computer Science; University: University of Memphis; Term: Spring 2006;
Typology: Study notes
1 / 35
This page cannot be seen from the preview
Don't miss anything!




























passing arguments (KW Ch.7) z exit status z if (KW Ch.8)
{^ test z^
debug
built-in commands {^
scripts {^
variables (local, environment) {^
redirection {^
wildcards {^
pipes {^
sequences {^
subshells {^
background processing {^
command substitution
the shell you use is a matter of taste, power,compatibility, and availability {^
C shell is better than Bourne shell for interactivework, but slightly worse in some respects forscript programming {^
Korn shell incorporates the best of features of theBourne shell and C shells {^
Bash also “best of all worlds”, includes featuresfrom all the other major shells {^
Bourne shell comes with every version of UNIX {^
Bash is the newest, is becoming the mostpopular, open software
Unix has a lot of commands, but there isno way it has everything {^
What do you do if no command existsthat does what you want?^ z^
Build it yourself! z^
The shell itself is actually a programminglanguage z^
A shell program/script consists of a sequentiallist of commands^ {
Value is known before execution, nottyped in during execution
z^
who
|^
grep $
./ison 6262-
only first 9 arguments are directly accessible via$1, $2, …, $ {^
for 10 or above use ${10}, ${11}, etc. {^
if more are supplied use shift command to accessthem^ z^
z^
z^
z^
z^
z^
z^
{^
example: testShift
0 - Success z Any other number – Failure z Used to inform other programs howthings went
variable $?^ z^
the exit status of the last command executed {^
in a pipeline, the exist status is that ofthe last command in the pipe {^
examples^ z^
who | grep 6262- z^
echo $? z^
who | grep good z^
echo $? z^
echo $?
z^
test evaluate
expression
z^
if the result is true, returns an exitstatus of 0 z^
otherwise, the result is false, returns anonzero exit status
Because this is used very often, ashortcut exists {^
[]^ z^
[ is the name of the command z^
still initiates execution of the same testcommand, only that test expects to see aclosing ] z^
spaces after [ and before ] {^
example^ z^
test –f tFile z^
[ -f tFile ]