The words Under construction in black text on a yellow background with diagonal black stipes surrounding it
I'm in the process of moving my site. It's still a work in progress. Please excuse the mess and broken links.

Create And Loop Through An Array Of Strings In Bash

TODO: Pull subtitle into page object

If all the values you're working with are single words you can process them as a string. See: 2so4kki3

This is how to create an array

Code
NAMES=("alfa bravo" "charlie delta" "echo foxtrot")

for name in "${NAMES[@]}"; do
  echo $name
done
Results
alfa bravo
charlie delta
echo foxtrot

Notes

Debugging Stuff

I'm moving stuff around right now. All this below is helping me figure out where to put stuff

        -- title

Create And Loop Through An Array Of Strings In Bash

-- note

If all the values you're working with are single 
words you can process them as a string. See:
2so4kki3

-- p

This is how to create an array


-- code
-- bash

NAMES=("alfa bravo" "charlie delta" "echo foxtrot")

for name in "${NAMES[@]}"; do
  echo $name
done

-- results

alfa bravo
charlie delta
echo foxtrot


-- notes

- Don't put commas between items in the array or they'll
show up in the output. (i.e. don't do _"alfa bravo", "charlie delta"__)

- The quotes around `${NAMES[@]}`bash` are necessary
to keep the strings from splitting on spaces



-- ref
-- url: https://www.gnu.org/software/bash/manual/html_node/Arrays.html

-- ref
-- url: https://www.gnu.org/software/bash/manual/html_node/Looping-Constructs.html

-- ref
-- url: https://www.freecodecamp.org/news/bash-array-how-to-declare-an-array-of-strings-in-a-bash-script/

-- ref
-- url: https://linuxhint.com/bash_loop_list_strings/


-- categories
-- Command Line 
-- Scripts 

-- metadata
-- date: 2023-07-19 16:22:45
-- id: 2so1yk03
-- site: aws
-- type: post
-- status: draft