The first line that identifies the file as a bash script
!/bin/bash
Comments begin with ____ and end at the end of the line
#
Gives the user (and others, if she wishes permission to execute it.
chmod +x filename
How to run a file from local dir.
./filename
Run with a trace - echo commands after expansion
bash -x ./filename
How to create a variable
Variablename=value (no spaces, no $)
How to read variable name?
read variablename (no $)
How to access a variable’s value
$variablename
Refereces the name of the script.
$0
Holds the value of the number of positional parameters
$#
Lists all of the positional parameters
$*
Means the same as $@, except when enclosed in double quotes
S@
Expands to a single argument (e.g., “$1 $2 $3”)
”$*”
Expands to separate arguments (e.g., “$1” “$2” “$3”)
“S@”
Command to reset the script arguments
set
Shows all the environment variables that exist
set | more
___ and ___ can be used as part f the list in a for loop or can be used as part of it
$* and $@
___ is evaluated to a single string
$*
___ is evaluated to a list of separate word
$@
What does <ctrl> do?</ctrl>
Exit new process
Reads a line from stdin into the variable answer
read answer
Reads a line from stdin up the whitespace, putting the first word in frsit and the rest of the line into last
read first last
Reads a line from stdin and assigns it to REPLY
read
Reads a list of word into an array called arrayname
read -a arrayname