basic vars

This commit is contained in:
2026-09-24 12:40:30 +01:00
parent 2ef1648142
commit bd76890b65
+39
View File
@@ -0,0 +1,39 @@
#!/bin/bash
# This script displays various information to the screen.
# Display 'Hello'
echo 'Hello'
# Assign a value to a variable.
WORD='script'
# Display that value using a variable.
echo "$WORD"
# Demonstrate that single quotes cause variable to NOT get expanded.
echo '$WORD'
# combine the variable with a hard-coded sentence
echo "this is a shell $WORD"
# Display the contents of a variable with alternative syntx
echo "This is a shell ${WORD}"
# append text to variable
echo "${WORD}ing is super fun!"
# how to NOT append text to a variable
echo "$WORDing is super fun!"
# Assign new variable
ENDING='ed'
# concat two variables
echo "This is ${WORD}${ENDING}"
# Reassign value of variable
ENDING='ing'
echo "This is ${WORD}${ENDING}"