|
|
@ -455,6 +455,8 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b |
|
|
|
<li><a href="#_expansion">1.2. expansion</a></li> |
|
|
|
</ul> |
|
|
|
</li> |
|
|
|
<li><a href="#_bash_positional_parameters">2. Bash Positional Parameters</a></li> |
|
|
|
<li><a href="#_extras">3. extras</a></li> |
|
|
|
</ul> |
|
|
|
</div> |
|
|
|
</div> |
|
|
@ -519,7 +521,20 @@ for i in "${!array[@]}"; do |
|
|
|
done |
|
|
|
|
|
|
|
echo "" |
|
|
|
echo ""</code></pre> |
|
|
|
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 |
|
|
|
)</code></pre> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
@ -533,12 +548,94 @@ echo "${!win}" # we print the variable linked by $win's content</cod |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="sect1"> |
|
|
|
<h2 id="_bash_positional_parameters">2. Bash Positional Parameters</h2> |
|
|
|
<div class="sectionbody"> |
|
|
|
<div class="ulist"> |
|
|
|
<ul> |
|
|
|
<li> |
|
|
|
<p>vim testvar.sh</p> |
|
|
|
</li> |
|
|
|
<li> |
|
|
|
<p>cut-paste</p> |
|
|
|
</li> |
|
|
|
<li> |
|
|
|
<p>chmod +x ./testvar.sh</p> |
|
|
|
</li> |
|
|
|
<li> |
|
|
|
<p>./testvar.sh a1 a2 a3 a4 a5 a6 a7 a8 a9 10 11 12 13</p> |
|
|
|
</li> |
|
|
|
</ul> |
|
|
|
</div> |
|
|
|
<div class="listingblock"> |
|
|
|
<div class="content"> |
|
|
|
<pre class="highlight"><code class="language-bash" data-lang="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</code></pre> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="sect1"> |
|
|
|
<h2 id="_extras">3. extras</h2> |
|
|
|
<div class="sectionbody"> |
|
|
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div id="footer"> |
|
|
|
<div id="footer-text"> |
|
|
|
Last updated 2020-11-30 22:45:51 UTC |
|
|
|
Last updated 2020-11-30 23:08:18 UTC |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</body> |
|
|
|