ao-mud is a spellbook of well-commented atomic bash scripts that each do one thing. we are building semantic building blocks for an autonomously-evolving digital spellcasting language.
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.

47 lines
1.4 KiB

#!/bin/sh
# To make this script executable, use the command: chmod +x 21_parentheses.sh
# To run the script, use the command: ./11_parentheses.sh
echo "This spell will teach you the basics of differentiating between similar parenthetical syntax in POSIX-compliant Bash"
echo "To study the code of the examples, please use the command: cat 21_parentheses.sh"
# Using $() command substitution
echo "Using command substitution with $()"
current_date=$(date)
echo "Today's date is: $current_date"
# Using $(()) arithmetic expansion
echo "Using arithmetic expansion with $(())"
num1=5
num2=3
result=$((num1 + num2))
echo "5 + 3 = $result"
# Using string list
echo "Using string list with \"\""
ingredients="Dragon's blood Unicorn hair Phoenix feather"
echo "Ingredients: $ingredients"
# Using array
echo "Using array with ()"
ingredients=("Dragon's blood" "Unicorn hair" "Phoenix feather")
echo "Ingredients: ${ingredients[@]}"
# Using [] test command
echo "Using test command with []"
string="Dragon's blood"
if [ "$string" = "Dragon's blood" ]; then
echo "The string is Dragon's blood"
else
echo "The string is not Dragon's blood"
fi
# Using [[]] test command
echo "Using test command with [[]]"
string="Dragon's blood"
if [[ "$string" = "Dragon's blood" ]]; then
echo "The string is Dragon's blood"
else
echo "The string is not Dragon's blood"
fi
echo "Spell cast successfully."