UNIX II – Shell Programming Basics

69 downloads 4522 Views 15KB Size Report
commands introduced in Lecture "Unix Basics". REFERENCE: Unix in a Nutshell, O'Reilly (less than $20). C Shell Programming Language Overview.
LECTURE

UNIX II – Shell Programming Basics OBJECTIVE: Be able to write simple Unix shell scripts containing the commands introduced in Lecture "Unix Basics". REFERENCE: Unix in a Nutshell, O'Reilly (less than $20). C Shell Programming Language Overview CONSTRUCT ----------------# echo xxxxx echo -n xxxxx exit repeat n command

EXPLANATION/EXAMPLE ----------------------------Comment line Display xxxxx; skips to next line. Displays xxxxx but does not skip. Exit from the shell script. Repeat command n times (e.g., to skip 3 lines: repeat 3 echo " ").

formal arguments

Arguments are passed when you invoke the script. they are named $1, $2, etc. The collection is named $argv. $2 is also $argv[2]. Local variables inside your shell script. Their value is referenced as $varname. Assignment statement: sets value of shell variable

variables set var=expression `command` set var=$