Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 129 additions & 0 deletions level-1-shell-scripting/basics/basics/README.md
Original file line number Diff line number Diff line change
@@ -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! 🚀
3 changes: 3 additions & 0 deletions level-1-shell-scripting/basics/basics/echo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
echo "Hello, World"
echo "My name is $name"
2 changes: 2 additions & 0 deletions level-1-shell-scripting/basics/basics/hello.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
echo "hello"
8 changes: 8 additions & 0 deletions level-1-shell-scripting/basics/basics/ifelse.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
name="Wooddang"

if [ "$name" = "Wooddang" ]; then
echo "Welcome, Wooddang!"
else
echo "Access denied"
fi
14 changes: 14 additions & 0 deletions level-1-shell-scripting/basics/basics/loops.sh
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions level-1-shell-scripting/basics/basics/variables.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
name="Wooddang"
age=30

echo $name
echo $age
Loading