From cdb288d7dadbc3ea9534c65f473002ce29d511e1 Mon Sep 17 00:00:00 2001 From: "CD@RKW8THN" <59784494+janikaralee@users.noreply.github.com> Date: Mon, 26 May 2025 23:20:48 -0700 Subject: [PATCH 1/8] Add files via upload --- markdown/Tutorial.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 markdown/Tutorial.md diff --git a/markdown/Tutorial.md b/markdown/Tutorial.md new file mode 100644 index 000000000..12ecbf5d7 --- /dev/null +++ b/markdown/Tutorial.md @@ -0,0 +1,14 @@ +# Tutorial +-------- +In Bash scripting, `elif` is used to handle multiple conditions in an `if` statement. It stands for "else if" and allows you to check additional conditions if the initial `if` condition is false. It's useful for branching logic beyond just `if` and `else`. + + Example: + +```bash +if [ $num -eq 1 ]; then + echo "One" +elif [ $num -eq 2 ]; then + echo "Two" +else + echo "Other" +fi From 8effa0f1b11e30144056e88c95f3de9feafaca68 Mon Sep 17 00:00:00 2001 From: "CD@RKW8THN" <59784494+janikaralee@users.noreply.github.com> Date: Mon, 26 May 2025 23:21:29 -0700 Subject: [PATCH 2/8] Update and rename Tutorial.md to elif.md --- markdown/{Tutorial.md => elif.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename markdown/{Tutorial.md => elif.md} (100%) diff --git a/markdown/Tutorial.md b/markdown/elif.md similarity index 100% rename from markdown/Tutorial.md rename to markdown/elif.md From b874a16190025489b6cc4d141513d40106737da8 Mon Sep 17 00:00:00 2001 From: "CD@RKW8THN" <59784494+janikaralee@users.noreply.github.com> Date: Mon, 26 May 2025 23:22:16 -0700 Subject: [PATCH 3/8] Delete markdown/elif.md --- markdown/elif.md | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 markdown/elif.md diff --git a/markdown/elif.md b/markdown/elif.md deleted file mode 100644 index 12ecbf5d7..000000000 --- a/markdown/elif.md +++ /dev/null @@ -1,14 +0,0 @@ -# Tutorial --------- -In Bash scripting, `elif` is used to handle multiple conditions in an `if` statement. It stands for "else if" and allows you to check additional conditions if the initial `if` condition is false. It's useful for branching logic beyond just `if` and `else`. - - Example: - -```bash -if [ $num -eq 1 ]; then - echo "One" -elif [ $num -eq 2 ]; then - echo "Two" -else - echo "Other" -fi From 396cebd28ed8c6430a587cb517f5019b9abd4cfd Mon Sep 17 00:00:00 2001 From: "CD@RKW8THN" <59784494+janikaralee@users.noreply.github.com> Date: Mon, 26 May 2025 23:23:13 -0700 Subject: [PATCH 4/8] Add files via upload --- markdown/elif.md | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 markdown/elif.md diff --git a/markdown/elif.md b/markdown/elif.md new file mode 100644 index 000000000..80a91392d --- /dev/null +++ b/markdown/elif.md @@ -0,0 +1,58 @@ +# Tutorial +-------- +In Bash scripting, `elif` is used to handle multiple conditions in an `if` statement. It stands for "else if" and allows you to check additional conditions if the initial `if` condition is false. It's useful for branching beyond just `if` and `else`. + + Example: + +```bash +if [ $num -eq 1 ]; then + echo "One" +elif [ $num -eq 2 ]; then + echo "Two" +else + echo "Other" +fi +``` + +# Exercise +In this exercise, you will need to use an `if`, `elif`, and `else` statement to evaluate the value of a variable called `color`. + +Your task is to: +- Print `"You chose black!"` if the value of `color` is `"black"` +- Print `"You chose green!"` if the value is `"green"` + +- Print `"You chose purple!"` if the value is `"purple"` +- Print `"You chose orange!"` if the value is `"orange"` +- Print `"Unknown/uncataloged color, please try again!"` for any other value + +Set `color="black"` to begin, and write the conditional logic that produces the correct output. + +# Tutorial Code +```bash +#!/bin/bash +#enter your code here +``` +# Expected Output +You chose black! + +# Solution +```bash +#!/bin/bash + +color="black" + +if [ "$color" == "black" ]; then + echo "You chose black!" +elif [ "$color" == "green" ]; then + echo "You chose green!" + +elif [ "$color" == "purple" ]; then + echo "You chose purple!" + +elif [ "$color" == "orange" ]; then + echo "You chose orange!" + +else + echo "Unknown/uncataloged color, please try again!" +fi +``` From 3d0200b4ebe93f1d23b0c6b8ba92ec8287423999 Mon Sep 17 00:00:00 2001 From: "CD@RKW8THN" <59784494+janikaralee@users.noreply.github.com> Date: Mon, 26 May 2025 23:33:46 -0700 Subject: [PATCH 5/8] Update Welcome.md --- tutorials/learnshell.org/en/Welcome.md | 1 + 1 file changed, 1 insertion(+) diff --git a/tutorials/learnshell.org/en/Welcome.md b/tutorials/learnshell.org/en/Welcome.md index ab6a4fe0b..bfa206003 100644 --- a/tutorials/learnshell.org/en/Welcome.md +++ b/tutorials/learnshell.org/en/Welcome.md @@ -20,6 +20,7 @@ Just click on the chapter you wish to begin from, and follow the instructions. G - [[Loops]] - [[Array-Comparison]] - [[Shell Functions]] +- [[elif]] ### Advanced Tutorials From ee96f4c3b36ef583d6462f1320653cd6732c1c4b Mon Sep 17 00:00:00 2001 From: "CD@RKW8THN" <59784494+janikaralee@users.noreply.github.com> Date: Mon, 26 May 2025 23:36:20 -0700 Subject: [PATCH 6/8] Add files via upload --- tutorials/learnshell.org/en/elif.md | 58 +++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 tutorials/learnshell.org/en/elif.md diff --git a/tutorials/learnshell.org/en/elif.md b/tutorials/learnshell.org/en/elif.md new file mode 100644 index 000000000..80a91392d --- /dev/null +++ b/tutorials/learnshell.org/en/elif.md @@ -0,0 +1,58 @@ +# Tutorial +-------- +In Bash scripting, `elif` is used to handle multiple conditions in an `if` statement. It stands for "else if" and allows you to check additional conditions if the initial `if` condition is false. It's useful for branching beyond just `if` and `else`. + + Example: + +```bash +if [ $num -eq 1 ]; then + echo "One" +elif [ $num -eq 2 ]; then + echo "Two" +else + echo "Other" +fi +``` + +# Exercise +In this exercise, you will need to use an `if`, `elif`, and `else` statement to evaluate the value of a variable called `color`. + +Your task is to: +- Print `"You chose black!"` if the value of `color` is `"black"` +- Print `"You chose green!"` if the value is `"green"` + +- Print `"You chose purple!"` if the value is `"purple"` +- Print `"You chose orange!"` if the value is `"orange"` +- Print `"Unknown/uncataloged color, please try again!"` for any other value + +Set `color="black"` to begin, and write the conditional logic that produces the correct output. + +# Tutorial Code +```bash +#!/bin/bash +#enter your code here +``` +# Expected Output +You chose black! + +# Solution +```bash +#!/bin/bash + +color="black" + +if [ "$color" == "black" ]; then + echo "You chose black!" +elif [ "$color" == "green" ]; then + echo "You chose green!" + +elif [ "$color" == "purple" ]; then + echo "You chose purple!" + +elif [ "$color" == "orange" ]; then + echo "You chose orange!" + +else + echo "Unknown/uncataloged color, please try again!" +fi +``` From cb1eb012c0eb244e1a305060e6e6814b587b9b19 Mon Sep 17 00:00:00 2001 From: "CD@RKW8THN" <59784494+janikaralee@users.noreply.github.com> Date: Mon, 26 May 2025 23:40:42 -0700 Subject: [PATCH 7/8] Delete markdown/elif.md --- markdown/elif.md | 58 ------------------------------------------------ 1 file changed, 58 deletions(-) delete mode 100644 markdown/elif.md diff --git a/markdown/elif.md b/markdown/elif.md deleted file mode 100644 index 80a91392d..000000000 --- a/markdown/elif.md +++ /dev/null @@ -1,58 +0,0 @@ -# Tutorial --------- -In Bash scripting, `elif` is used to handle multiple conditions in an `if` statement. It stands for "else if" and allows you to check additional conditions if the initial `if` condition is false. It's useful for branching beyond just `if` and `else`. - - Example: - -```bash -if [ $num -eq 1 ]; then - echo "One" -elif [ $num -eq 2 ]; then - echo "Two" -else - echo "Other" -fi -``` - -# Exercise -In this exercise, you will need to use an `if`, `elif`, and `else` statement to evaluate the value of a variable called `color`. - -Your task is to: -- Print `"You chose black!"` if the value of `color` is `"black"` -- Print `"You chose green!"` if the value is `"green"` - -- Print `"You chose purple!"` if the value is `"purple"` -- Print `"You chose orange!"` if the value is `"orange"` -- Print `"Unknown/uncataloged color, please try again!"` for any other value - -Set `color="black"` to begin, and write the conditional logic that produces the correct output. - -# Tutorial Code -```bash -#!/bin/bash -#enter your code here -``` -# Expected Output -You chose black! - -# Solution -```bash -#!/bin/bash - -color="black" - -if [ "$color" == "black" ]; then - echo "You chose black!" -elif [ "$color" == "green" ]; then - echo "You chose green!" - -elif [ "$color" == "purple" ]; then - echo "You chose purple!" - -elif [ "$color" == "orange" ]; then - echo "You chose orange!" - -else - echo "Unknown/uncataloged color, please try again!" -fi -``` From 354997ed742da1e5fecb5c7ec581baa6ae9ccaa3 Mon Sep 17 00:00:00 2001 From: "CD@RKW8THN" <59784494+janikaralee@users.noreply.github.com> Date: Mon, 26 May 2025 23:41:49 -0700 Subject: [PATCH 8/8] Update elif.md --- tutorials/learnshell.org/en/elif.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tutorials/learnshell.org/en/elif.md b/tutorials/learnshell.org/en/elif.md index 80a91392d..1d53c15ac 100644 --- a/tutorials/learnshell.org/en/elif.md +++ b/tutorials/learnshell.org/en/elif.md @@ -56,3 +56,5 @@ else echo "Unknown/uncataloged color, please try again!" fi ``` + +[[Welcome]]