From 04f8340376db945b0b1fcef0f2de2670c86b9baf Mon Sep 17 00:00:00 2001 From: RonaldsonBellande Date: Tue, 24 Sep 2024 18:39:42 -0400 Subject: [PATCH] latest pushes --- bellos_scripts/basic_math.bellos | 22 ++++++++++++++++ bellos_scripts/control_structures.bellos | 31 +++++++++++++++++++++++ bellos_scripts/file_operations.bellos | 23 +++++++++++++++++ bellos_scripts/functions.bellos | 17 +++++++++++++ bellos_scripts/hello_world.bellos | 9 +++++++ bellos_scripts/string_manipulation.bellos | 23 +++++++++++++++++ 6 files changed, 125 insertions(+) create mode 100644 bellos_scripts/basic_math.bellos create mode 100644 bellos_scripts/control_structures.bellos create mode 100644 bellos_scripts/file_operations.bellos create mode 100644 bellos_scripts/functions.bellos create mode 100644 bellos_scripts/hello_world.bellos create mode 100644 bellos_scripts/string_manipulation.bellos diff --git a/bellos_scripts/basic_math.bellos b/bellos_scripts/basic_math.bellos new file mode 100644 index 0000000..32f590b --- /dev/null +++ b/bellos_scripts/basic_math.bellos @@ -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 diff --git a/bellos_scripts/control_structures.bellos b/bellos_scripts/control_structures.bellos new file mode 100644 index 0000000..287143c --- /dev/null +++ b/bellos_scripts/control_structures.bellos @@ -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 diff --git a/bellos_scripts/file_operations.bellos b/bellos_scripts/file_operations.bellos new file mode 100644 index 0000000..828eda7 --- /dev/null +++ b/bellos_scripts/file_operations.bellos @@ -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 + diff --git a/bellos_scripts/functions.bellos b/bellos_scripts/functions.bellos new file mode 100644 index 0000000..072f119 --- /dev/null +++ b/bellos_scripts/functions.bellos @@ -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" diff --git a/bellos_scripts/hello_world.bellos b/bellos_scripts/hello_world.bellos new file mode 100644 index 0000000..4dd48f5 --- /dev/null +++ b/bellos_scripts/hello_world.bellos @@ -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!" diff --git a/bellos_scripts/string_manipulation.bellos b/bellos_scripts/string_manipulation.bellos new file mode 100644 index 0000000..3adc8c7 --- /dev/null +++ b/bellos_scripts/string_manipulation.bellos @@ -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,,}" +