From f6e44dc3a0d208184f6e346f4fcac2ad54c1bc2f Mon Sep 17 00:00:00 2001 From: wooddang-gachon Date: Fri, 16 Jan 2026 14:44:14 +0900 Subject: [PATCH 1/3] Add syntax example --- level-1-shell-scripting/basics/basics/echo.sh | 2 ++ level-1-shell-scripting/basics/basics/ifelse.sh | 7 +++++++ level-1-shell-scripting/basics/basics/loops.sh | 14 ++++++++++++++ level-1-shell-scripting/basics/basics/variables.sh | 2 ++ 4 files changed, 25 insertions(+) create mode 100644 level-1-shell-scripting/basics/basics/echo.sh create mode 100644 level-1-shell-scripting/basics/basics/ifelse.sh 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..1107f3e --- /dev/null +++ b/level-1-shell-scripting/basics/basics/echo.sh @@ -0,0 +1,2 @@ +echo "Hello, World" +echo "My name is $name" 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..16a86be --- /dev/null +++ b/level-1-shell-scripting/basics/basics/ifelse.sh @@ -0,0 +1,7 @@ +name="Hyunwoo" + +if [ "$name" = "Hyunwoo" ]; then + echo "Welcome, Hyunwoo!" +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..507367b 100644 --- a/level-1-shell-scripting/basics/basics/loops.sh +++ b/level-1-shell-scripting/basics/basics/loops.sh @@ -0,0 +1,14 @@ + +# for while loop examples +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..a9eb6e8 100644 --- a/level-1-shell-scripting/basics/basics/variables.sh +++ b/level-1-shell-scripting/basics/basics/variables.sh @@ -0,0 +1,2 @@ +echo $name +echo $age From 2ad412783bf650820c21f8721ed14b3e2477f8e5 Mon Sep 17 00:00:00 2001 From: wooddang-gachon Date: Fri, 16 Jan 2026 14:56:21 +0900 Subject: [PATCH 2/3] add syntsx example --- level-1-shell-scripting/basics/basics/echo.sh | 1 + level-1-shell-scripting/basics/basics/hello.sh | 2 ++ level-1-shell-scripting/basics/basics/ifelse.sh | 7 ++++--- level-1-shell-scripting/basics/basics/loops.sh | 2 +- level-1-shell-scripting/basics/basics/variables.sh | 4 ++++ 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/level-1-shell-scripting/basics/basics/echo.sh b/level-1-shell-scripting/basics/basics/echo.sh index 1107f3e..4f601bf 100644 --- a/level-1-shell-scripting/basics/basics/echo.sh +++ b/level-1-shell-scripting/basics/basics/echo.sh @@ -1,2 +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 index 16a86be..daf143b 100644 --- a/level-1-shell-scripting/basics/basics/ifelse.sh +++ b/level-1-shell-scripting/basics/basics/ifelse.sh @@ -1,7 +1,8 @@ -name="Hyunwoo" +#!/bin/bash +name="Wooddang" -if [ "$name" = "Hyunwoo" ]; then - echo "Welcome, Hyunwoo!" +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 507367b..c833368 100644 --- a/level-1-shell-scripting/basics/basics/loops.sh +++ b/level-1-shell-scripting/basics/basics/loops.sh @@ -1,5 +1,5 @@ -# for while loop examples +#!/bin/bash for i in 1 2 3 4 5 do echo "Number: $i" diff --git a/level-1-shell-scripting/basics/basics/variables.sh b/level-1-shell-scripting/basics/basics/variables.sh index a9eb6e8..7f1d63f 100644 --- a/level-1-shell-scripting/basics/basics/variables.sh +++ b/level-1-shell-scripting/basics/basics/variables.sh @@ -1,2 +1,6 @@ +#!/bin/bash +name="Wooddang" +age=30 + echo $name echo $age From 519b5154e19ad8b125b3d88a2a498872c8fdda5e Mon Sep 17 00:00:00 2001 From: wooddang-gachon Date: Sun, 18 Jan 2026 12:48:43 +0900 Subject: [PATCH 3/3] add README.md in basics --- .../basics/basics/README.md | 129 ++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 level-1-shell-scripting/basics/basics/README.md 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! 🚀