Bash (Borne Again Shell)

[top] Arrays

ARRAY=('item1' 'item2' 'item3');

item1 = $ARRAY[0];
item2 = $ARRAY[1];
item3 = $ARRAY[2];
Set an array with three items. Then set a seperate variable to each array element's item name.


[top] Do loop

for i in `ls`; 
do
	echo $i
done
This will get a listing of the current directory and then echo its contents to the screen.


[top] Functions

myfunc() {
	...
	param1 = $1;
	param2 = $2;
	param3 = $3;

	function contents
	...
}

myfunc ;
Set function and get the parameters passed.

myfunc ("item1" "item2" "item3");
Call function and pass in three parameters.


[top] Set $PS1 (prompt)

 PS1='[\u(`id -gn`)@\h] \w% '
[steved(grouper)@blackbox] /home/steved% _
Sets the prompt accordingly:
\u = user
\h = hostname
\w = current working directory
`id -gn` = current group


[top] Set $TERM

 TERM=vt100
> echo $TERM
vt100
Sets the current shells $TERM variable to vt100.  To verify type echo $TERM.