Skip to content

Instantly share code, notes, and snippets.

@huevos-y-bacon
Created February 23, 2022 12:08
Show Gist options
  • Save huevos-y-bacon/33ba4949829e64aa1591c960e44e0b5d to your computer and use it in GitHub Desktop.
Save huevos-y-bacon/33ba4949829e64aa1591c960e44e0b5d to your computer and use it in GitHub Desktop.
Bash Arrays - Add Elements
#!/usr/bin/env bash
array=(pluto pippo bob)
echo "array: ${array[*]}"
echo
addlist=(mike john)
echo "add list: ${addlist[*]}"
array+=(${addlist[*]})
echo "${array[@]}"
echo
addsingle=peter
echo "add single INcorrectly: $addsingle"
array+="${addsingle}"
echo "${array[@]}"
echo
echo "add single correctly: $addsingle"
array+=(${addsingle})
echo "${array[@]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment