Created
February 23, 2022 12:08
-
-
Save huevos-y-bacon/33ba4949829e64aa1591c960e44e0b5d to your computer and use it in GitHub Desktop.
Bash - Arrays - Add Elements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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