diff --git a/level-1-shell-scripting/basics/basics/README.md b/level-1-shell-scripting/basics/basics/README.md new file mode 100644 index 0000000..dea3090 --- /dev/null +++ b/level-1-shell-scripting/basics/basics/README.md @@ -0,0 +1,129 @@ +# Basic Shell Scripting Examples + +This folder contains **basic Bash shell scripting examples** for beginners. +Each script demonstrates a core concept commonly used in shell scripting. + +--- + +## Prerequisites + +* Linux / macOS terminal (or Git Bash / WSL on Windows) +* Bash shell +* Basic terminal knowledge (`cd`, `ls`) + +Make scripts executable (optional): + +```bash +chmod +x *.sh +``` + +--- + +## Scripts Overview + +### 1️⃣ `variables.sh` + +**What it demonstrates** + +* How to declare and use variables in Bash + +**How to run** + +```bash +bash variables.sh +``` + +**What you should learn** + +* Variable assignment syntax +* How to reference variables using `$` +* Difference between strings and variables + +--- + +### 2️⃣ `echo.sh` + +**What it demonstrates** + +* Printing output to the terminal using `echo` + +**How to run** + +```bash +bash echo.sh +``` + +**What you should learn** + +* How to display text +* How to print variables +* Basic output formatting + +--- + +### 3️⃣ `if_else.sh` + +**What it demonstrates** + +* Conditional logic using `if`, `else` + +**How to run** + +```bash +bash if_else.sh +``` + +**What you should learn** + +* How conditions work in Bash +* Using comparison operators +* Controlling script flow based on conditions + +--- + +### 4️⃣ `loops.sh` + +**What it demonstrates** + +* Looping with `for` (and/or `while`) + +**How to run** + +```bash +bash loops.sh +``` + +**What you should learn** + +* Repeating commands using loops +* Iterating over values +* Automating repetitive tasks + +--- + +### 5️⃣ `hello.sh` + +**What it demonstrates** + +* A simple end-to-end Bash script + +**How to run** + +```bash +bash hello.sh +``` + +**What you should learn** + +* Basic script structure +* Using `echo` +* Running a shell script from the terminal + +--- + +## Notes + +* These examples are intentionally simple for learning purposes. +* Try editing the scripts and re-running them to better understand how Bash works. + +Happy scripting! 🚀 diff --git a/level-1-shell-scripting/basics/basics/echo.sh b/level-1-shell-scripting/basics/basics/echo.sh new file mode 100644 index 0000000..4f601bf --- /dev/null +++ b/level-1-shell-scripting/basics/basics/echo.sh @@ -0,0 +1,3 @@ +#!/bin/bash +echo "Hello, World" +echo "My name is $name" diff --git a/level-1-shell-scripting/basics/basics/hello.sh b/level-1-shell-scripting/basics/basics/hello.sh index e69de29..57ac3b2 100755 --- a/level-1-shell-scripting/basics/basics/hello.sh +++ b/level-1-shell-scripting/basics/basics/hello.sh @@ -0,0 +1,2 @@ +#!/bin/bash +echo "hello" \ No newline at end of file diff --git a/level-1-shell-scripting/basics/basics/ifelse.sh b/level-1-shell-scripting/basics/basics/ifelse.sh new file mode 100644 index 0000000..daf143b --- /dev/null +++ b/level-1-shell-scripting/basics/basics/ifelse.sh @@ -0,0 +1,8 @@ +#!/bin/bash +name="Wooddang" + +if [ "$name" = "Wooddang" ]; then + echo "Welcome, Wooddang!" +else + echo "Access denied" +fi diff --git a/level-1-shell-scripting/basics/basics/loops.sh b/level-1-shell-scripting/basics/basics/loops.sh index e69de29..c833368 100644 --- a/level-1-shell-scripting/basics/basics/loops.sh +++ b/level-1-shell-scripting/basics/basics/loops.sh @@ -0,0 +1,14 @@ + +#!/bin/bash +for i in 1 2 3 4 5 +do + echo "Number: $i" +done + +count=1 + +while [ $count -le 3 ] +do + echo "Count is $count" + count=$((count + 1)) +done diff --git a/level-1-shell-scripting/basics/basics/variables.sh b/level-1-shell-scripting/basics/basics/variables.sh index e69de29..7f1d63f 100644 --- a/level-1-shell-scripting/basics/basics/variables.sh +++ b/level-1-shell-scripting/basics/basics/variables.sh @@ -0,0 +1,6 @@ +#!/bin/bash +name="Wooddang" +age=30 + +echo $name +echo $age