3.3 Turning Commands into a Script Flashcards
Scripting
numerical comparison
not equal to
-ne
Scripting
numerical comparison
greater than
-gt
Scripting
numerical comparison
greater than or equal to
-ge
Scripting
numerical comparison
less than
-lt
Scripting
numerical comparison
less than or equal to
-le
Scripting
a simple script that will check if exactly two arguments are passed. If so, print the
arguments in reverse order.
if [ $1 == $number ]
then
echo “True!”
fi
Scripting
arguments
positional
$1, $2, … $9
Scripting
arguments
contains number of args passed to script
$#
Scripting
arguments
contains directories that have executable used by the system
$PATH
Scripting
all scripts begin with this character that defines the path to the interpreter
shebang
Scripting
remove first element of an array
shift
Scripting
contain exit code of last command executed
$?
Scripting
contain all args passed to the script as an array
$@, $*