Answers for "add element to array bash script for loop"

25

loop from array bash

#!/bin/bash
# declare an array called array and define 3 values
array=( one two three )
for i in "${array[@]}"
do
	echo $i
done
Posted by: Guest on April-13-2020
5

bash adding to array

#!/bin/bash

#Making an array
array=(1 2 3)

#Appending the array
array+=(4)

#Printing the array
echo ${array[@]}
Posted by: Guest on February-24-2021

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language