latest pushes
This commit is contained in:
parent
80430e9e6a
commit
28448d55de
22
bellos_scripts/basic_math.bellos
Normal file
22
bellos_scripts/basic_math.bellos
Normal file
@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bellos
|
||||
# File: file_operations.bellos
|
||||
|
||||
# Demonstrating file operations
|
||||
|
||||
# Writing to a file
|
||||
echo "This is a test file" > test.txt
|
||||
echo "Adding another line" >> test.txt
|
||||
|
||||
# Reading from a file
|
||||
echo "Contents of test.txt:"
|
||||
cat test.txt
|
||||
|
||||
# Using a while loop to read file line by line
|
||||
echo "Reading file line by line:"
|
||||
while read -r line
|
||||
do
|
||||
echo "Line: $line"
|
||||
done < test.txt
|
||||
|
||||
# Cleaning up
|
||||
rm test.txt
|
31
bellos_scripts/control_structures.bellos
Normal file
31
bellos_scripts/control_structures.bellos
Normal file
@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bellos
|
||||
# File: control_structures.bellos
|
||||
|
||||
# Demonstrating if statements and loops
|
||||
|
||||
# If statement
|
||||
if [ $# -eq 0 ]
|
||||
then
|
||||
echo "No arguments provided"
|
||||
elif [ $# -eq 1 ]
|
||||
then
|
||||
echo "One argument provided: $1"
|
||||
else
|
||||
echo "Multiple arguments provided"
|
||||
fi
|
||||
|
||||
# For loop
|
||||
echo "Counting from 1 to 5:"
|
||||
for i in 1 2 3 4 5
|
||||
do
|
||||
echo $i
|
||||
done
|
||||
|
||||
# While loop
|
||||
echo "Countdown:"
|
||||
count=5
|
||||
while [ $count -gt 0 ]
|
||||
do
|
||||
echo $count
|
||||
count=$((count - 1))
|
||||
done
|
23
bellos_scripts/file_operations.bellos
Normal file
23
bellos_scripts/file_operations.bellos
Normal file
@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bellos
|
||||
# File: file_operations.bellos
|
||||
|
||||
# Demonstrating file operations
|
||||
|
||||
# Writing to a file
|
||||
echo "This is a test file" > test.txt
|
||||
echo "Adding another line" >> test.txt
|
||||
|
||||
# Reading from a file
|
||||
echo "Contents of test.txt:"
|
||||
cat test.txt
|
||||
|
||||
# Using a while loop to read file line by line
|
||||
echo "Reading file line by line:"
|
||||
while read -r line
|
||||
do
|
||||
echo "Line: $line"
|
||||
done < test.txt
|
||||
|
||||
# Cleaning up
|
||||
rm test.txt
|
||||
|
17
bellos_scripts/functions.bellos
Normal file
17
bellos_scripts/functions.bellos
Normal file
@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env bellos
|
||||
# File: functions.bellos
|
||||
|
||||
# Defining and using functions
|
||||
|
||||
function greet() {
|
||||
echo "Hello, $1!"
|
||||
}
|
||||
|
||||
function add() {
|
||||
echo $(($1 + $2))
|
||||
}
|
||||
|
||||
# Calling functions
|
||||
greet "User"
|
||||
result=$(add 3 4)
|
||||
echo "3 + 4 = $result"
|
9
bellos_scripts/hello_world.bellos
Normal file
9
bellos_scripts/hello_world.bellos
Normal file
@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bellos
|
||||
# File: hello_world.bellos
|
||||
|
||||
# Simple Hello World script
|
||||
echo "Hello, World!"
|
||||
|
||||
# Using variables
|
||||
name="Bellos"
|
||||
echo "Welcome to $name programming!"
|
23
bellos_scripts/string_manipulation.bellos
Normal file
23
bellos_scripts/string_manipulation.bellos
Normal file
@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bellos
|
||||
# File: string_manipulation.bellos
|
||||
|
||||
# Demonstrating string manipulation
|
||||
|
||||
string="Hello, Bellos!"
|
||||
|
||||
# String length
|
||||
echo "Length of string: ${#string}"
|
||||
|
||||
# Substring
|
||||
echo "First 5 characters: ${string:0:5}"
|
||||
|
||||
# String replacement
|
||||
new_string=${string/Bellos/World}
|
||||
echo "Replaced string: $new_string"
|
||||
|
||||
# Converting to uppercase
|
||||
echo "Uppercase: ${string^^}"
|
||||
|
||||
# Converting to lowercase
|
||||
echo "Lowercase: ${string,,}"
|
||||
|
Loading…
Reference in New Issue
Block a user