FreeKB - Append values to an array (+=)
Bash Shell Scripting - Append values to an array (+=)

Let's say you have an array of fruit.

fruit=(banana apple orange grapes)

 

The += operator can be used to append values to the array. In this example, pineapple is appended to the fruit array.

fruit+=(pineapple)

 

The array can be printed.

echo $fruit

 

Echoing the array will show that pineapple has been appended to the array.

banana apple orange grapes pineapple

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter 5ec68 in the box below so that we can be sure you are a human.




Comments