Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

bash adding to array

#!/bin/bash

#Making an array
array=(1 2 3)

#Appending the array
array+=(4)

#Printing the array
echo ${array[@]}
Comment

bash array append

for i in $(seq 2.5 .1 5);
do
    # Print the value
    echo $i " ########";
    arrVar+=($i) # appending 

done

# Iterate the loop to read and print each array element
for value in "${arrVar[@]}"
do
     echo $value
done

other ways : https://linuxhint.com/bash_append_array/


2.5
2.6
2.7
2.8
2.9
Comment

PREVIOUS NEXT
Code Example
Shell :: install cyberpanel centos 7 
Shell :: git exclude folder 
Shell :: docker nodejs 
Shell :: git config --list 
Shell :: install version 3.9 conda environment 
Shell :: bash assigning to new array 
Shell :: how to add line number to a file 
Shell :: how to compare files in terminal 
Shell :: linux sync files between folders 
Shell :: write content in file powershell 
Shell :: Flutter plugin not installed; this adds Flutter specific functionality. 
Shell :: generate uml from python code 
Shell :: git client 
Shell :: linux run .sh in terminal 
Shell :: custom jenkins dockerfile 
Shell :: bash for loop step 
Shell :: symfony gitignore 
Shell :: cannot update paths and switch to branch at the same time 
Shell :: install jupyter 
Shell :: speed up ffmpeg video 
Shell :: git get access to private repository 
Shell :: ppsspp debian 10 
Shell :: run existing image docker 
Shell :: how to install imsomnia on manjaro linux 
Shell :: windows server 2016 install chrome 
Shell :: vim delete to end of file 
Shell :: mdem ubuntu add user to sudo 
Shell :: view certificate openssl 
Shell :: comment installer virtualbox sur kali linux 
Shell :: scp linux to mac 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =