ADV PROG DAY 3 Flashcards
When used, returns all the values in the array as a single value. The * can be replaced with an index number to return the value in that element.
${name[*]}
When used,returns the number of elements in the array. The * can be replaced with an index number to return the length of that value.
${#name[*]}
Stores name of command used to call current program.
$0
Stores number of arguments passed to script or function.
$#
References all arguments passed to script or function.
$*
Stores first nine arguments in incrementing variables passed to script or function.
$1, $2, $3, …$9
Stores exit status of previous command.
$?
For Bash:
Substitutes variables and escaped characters with their actual values.
Double Quotes “”
For Bash:
Makes everything literal so the values of variables are not substituted.
Single Quotes ‘’
For Bash:
Used to capture the output of a command. A command enclosed in back quotes is replaced by the STDOUT of that command. Shell variable values are substituted within back quotes.
Back Quotes ` `
A script reads a line from the keyboard .
assigns the contents of the input to the variable listed. The following example shows two input styles.
read command
–p allows a double quoted prompt.
sorts the contents of a text file, line by line.
sort command
provides the ability to evaluate a wide range of arithmetic expressions. It evaluates its arguments as expressions and returns the result.
The spacing in an expression is critical.
expr tool