basic vars
This commit is contained in:
Executable
+39
@@ -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}"
|
||||
Reference in New Issue
Block a user