From a44d97973757de7d57ea64bf1ad830bc188ccd6d Mon Sep 17 00:00:00 2001 From: daryl Date: Fri, 1 Jul 2022 11:39:26 +0930 Subject: [PATCH 1/2] Add 'bash/array_append.bash' --- bash/array_append.bash | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 bash/array_append.bash diff --git a/bash/array_append.bash b/bash/array_append.bash new file mode 100644 index 0000000..7368c06 --- /dev/null +++ b/bash/array_append.bash @@ -0,0 +1,13 @@ +#!/bin/bash + +# Declare a string array +arrVar=("AC" "TV" "Mobile" "Fridge" "Oven" "Blender") + +# Add new element at the end of the array +arrVar+=("Dish Washer") + +# Iterate the loop to read and print each array element +for value in "${arrVar[@]}" +do + echo $value +done From 79034b2888571dc3ff6fa60bb74e46a83b8de416 Mon Sep 17 00:00:00 2001 From: daryl Date: Fri, 1 Jul 2022 11:40:06 +0930 Subject: [PATCH 2/2] Update 'bash/README.md' --- bash/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bash/README.md b/bash/README.md index 2b107e3..dea786b 100644 --- a/bash/README.md +++ b/bash/README.md @@ -4,6 +4,10 @@ Handling command line argument / parameter parsing at the beginning of a script. +## array_append.bash + +How to declare an array, append new elements, iterate over the array for processing. + ## booleans.bash BASH doesn't actually have booleans, but there's tricks to make variables behave enough like bools to be useful.