You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
1.1 KiB
79 lines
1.1 KiB
4 years ago
|
= 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 <<EOF
|
||
|
declare -A array=(
|
||
|
[1,0]="first name"
|
||
|
[1,1]="second name"
|
||
|
[2,0]="third name"
|
||
|
[3,0]="foo bar"
|
||
|
[test 1]="test bar"
|
||
|
)
|
||
|
EOF
|
||
|
)
|
||
|
|
||
|
echo "$var"
|
||
|
|
||
|
cat <<'EOF'
|
||
|
----------------------------------------------------------
|
||
|
for with "${!array[@]}"
|
||
|
----------------------------------------------------------
|
||
|
for i in "${!array[@]}"; do
|
||
|
echo "$i => ${array[$i]}";
|
||
|
done
|
||
|
|
||
|
"result: "
|
||
|
EOF
|
||
|
|
||
|
for i in "${!array[@]}"; do
|
||
|
echo "$i => ${array[$i]}";
|
||
|
done
|
||
|
|
||
|
echo ""
|
||
|
echo ""
|
||
|
|
||
|
----
|
||
|
|
||
|
|
||
|
=== 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
|
||
|
----
|
||
|
|