Introduction to Bash Scripting
Alex Scriven
Data Scientist
Chapter 1 - The basics:
ARGV is the array of all the arguments given to the program. ARGV is vital knowledge.
$
notation. ($1
, $2
etc.)$@
(and $*
) return all the arguments in ARGV$#
gives the length (number) of argumentsIn an example script.sh
:
#!/usr/bash
echo $1
echo $@
Call with bash script.sh FirstArg SecondArg
FirstArg
FirstAg SecondArg
You learned about creating and using different Bash variables including:
expr
and (for decimals) bc
$
and
backticks)A concept we used again and again (and again!) was the shell-within-a-shell.
sum=$(expr 4 + 5)
echo $sum
9
Mastering control of your scripts with:
Introduction to Bash Scripting