Answers for "bash array"

10

bash array

# create an array - just assign first value
arrayname[0]='VALUE'

# define an array
declare -a arrayname=(element1 element2 element3)

# get array element at index 
${arrayname[2]}

# get all array elements
${arrayname[@]}

# get array length
${#arrayname[@]}
Posted by: Guest on October-09-2020
4

how to make a list bash

#to create an array:
$ declare -a my_array
#set number of items with spaceBar seperation:
$ my_array = (item1 item2)
#set specific index item:
$ my_array[0] = item1
Posted by: Guest on July-11-2020
0

bash array

ss="abcdefghi"
my_array=( `echo $ss | grep -o . ` ) # split word into array

echo ${my_array[2]} 
give c

i=0
echo ${my_array[$i]}${my_array[$i+1]}xxx
give : abxxx
Posted by: Guest on August-23-2021

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language