bellos/bellos_scripts/string_manipulation.bellos
2024-10-15 22:47:29 -04:00

55 lines
1.2 KiB
Plaintext
Executable File

#!/usr/bin/env bellos
# File: string_manipulation.bellos
# Demonstrating basic string manipulation in Bellos
# String assignment
echo "String assignment:"
first_name=John
last_name=Doe
echo "first_name: $first_name"
echo "last_name: $last_name"
echo
# String concatenation
echo "String concatenation:"
full_name="$first_name $last_name"
echo full_name: $full_name
echo
# Using strings in commands
echo "Using strings in commands:"
greeting=Hello
echo "$greeting, $full_name!"
echo
# Quoting strings
echo "Quoting strings:"
sentence="The quick brown fox jumps over the lazy dog"
echo With double quotes: "$sentence"
echo With single quotes: '$sentence'
echo
# Assigning command output to a variable
echo "Assigning command output to a variable:"
current_date=10-17-2025
echo "The current date is: $current_date"
echo
# Escaping special characters
echo "Escaping special characters:"
path=/home/user/documents
echo "Path with slashes: $path"
echo "Dollar sign: $100"
echo
# Using variables in paths
echo "Using variables in paths:"
username=johndoe
user_home=/home/$username
echo "User's home directory: $user_home"
echo
# Completion message
echo "String manipulation operations completed."