bellos/bellos_scripts/string_manipulation.bellos

55 lines
1.2 KiB
Plaintext
Raw Permalink Normal View History

2024-09-24 22:39:42 +00:00
#!/usr/bin/env bellos
2024-10-16 02:47:29 +00:00
# File: string_manipulation.bellos
# Demonstrating basic string manipulation in Bellos
2024-09-24 22:39:42 +00:00
2024-10-16 02:47:29 +00:00
# String assignment
echo "String assignment:"
2024-10-05 01:12:19 +00:00
first_name=John
last_name=Doe
2024-10-16 02:47:29 +00:00
echo "first_name: $first_name"
echo "last_name: $last_name"
echo
2024-09-24 22:39:42 +00:00
2024-10-16 02:47:29 +00:00
# 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:"
2024-10-03 04:14:47 +00:00
sentence="The quick brown fox jumps over the lazy dog"
2024-10-16 02:47:29 +00:00
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
2024-10-03 04:14:47 +00:00
2024-10-05 15:54:36 +00:00
# Completion message
2024-10-16 02:47:29 +00:00
echo "String manipulation operations completed."