= An Introduction to Linux ! Apostolos rootApostolos@swarmlab.io // Metadata: :description: Intro and Install :keywords: Linux, apt :data-uri: :toc: right :toc-title: Πίνακας περιεχομένων :toclevels: 4 :source-highlighter: highlight :icons: font :sectnums: {empty} + .NOTE [NOTE] ==== Assuming you're already logged in ==== == heredoc === Exercise [source,bash] ---- #!/bin/bash var=$(cat < ${array[$i]}"; done "result: " EOF for i in "${!array[@]}"; do echo "$i => ${array[$i]}"; done echo "" echo "" cat << FOE > testfile.sh declare -A array=( [1,0]="first name" [1,1]="second name" [2,0]="third name" [3,0]="foo bar" [test 1]="test bar" ) EOF ) ---- === expansion [source,bash] ---- real_fc="barca" # set real_fc win="real_fc" # $win is "real_fc" echo "${!win}" # we print the variable linked by $win's content ---- == Bash Positional Parameters - vim testvar.sh - cut-paste - chmod +x ./testvar.sh - ./testvar.sh a1 a2 a3 a4 a5 a6 a7 a8 a9 10 11 12 13 [source,bash] ---- echo $# echo $@ echo $? cat <<'EOF' $# = number of arguments. $@ = what parameters were passed. $* = what parameters were passed. $? = was last command successful. Answer is 0 which means 'yes' EOF cat << FOE > testfile.sh #!/bin/bash RUSER=$1 ID=$2 SERVICE=$3 SERVICE_STACK=$4 VNCport=$5 RREPLICAS=$6 RREGION=$7 TTYport=$8 PASSWORDrw=$9 PASSWORDview=${10} GIT_TUTOR=${11} REBOOT=${12} USERscope=${13} FOE chmod +x ./testfile.sh #./testfile.sh # cat << 'FOE' > testfile1.sh #!/bin/bash RUSER=$1 ID=$2 SERVICE=$3 SERVICE_STACK=$4 VNCport=$5 RREPLICAS=$6 RREGION=$7 TTYport=$8 PASSWORDrw=$9 PASSWORDview=${10} GIT_TUTOR=${11} REBOOT=${12} USERscope=${13} FOE chmod +x ./testfile1.sh ---- == extras