Intro to Bash Scripting

Shell Variables

x=1 # string value 1
fullname="James Huang" # note - no whitespace between variable name, equals symbols, and valued assigned, if variable value has whitespace, use quotes
word=hard
echo ${word} # hard
echo ${word}er # harder - word is substituted in
dir=~/cs136 # create variable named dir, assign to string which is path to file called cs136 - no output
echo $dir # echos directory variable
cd ${dir} # enter directory variable
ls ${dir} # list files in directory
echo ${dir}/a1 # concat characters
Variable Meaning
${PWD} present working directory (equivalent to executing pwd)
${HOME} your home directory (equivalent to ~)
${SHELL} your default shell
${PRINTER} your default printer
${HOSTNAME} your machine's name
${PATH} your default search path for commands and programs

Command Line Arguments