M
M
MaxLoL03772020-02-18 20:25:08
bash
MaxLoL0377, 2020-02-18 20:25:08

2D Bash array?

Good day to all! Ask for advice from experienced people. There is a bash script that carries 2 arrays. I need the 1st value of one array to be on the same line as the value of the 2nd array, and so on. An example of my paws (as I saw it) is below.
array=($timestamp)
array2=($videoname)
array3=(${array[@]}${array2[@]})
echo $array3
I know I'm wrong, but Google didn't help, so I'm asking for advice from all of you .

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Shitskov, 2020-02-18
@Zarom

#!/bin/bash

array=(a b c)
array2=(1 2 3)

for (( i=0; i<${#array[@]}; i++ ))
do
        echo "${array[$i]}${array2[$i]}"
done

X
xibir, 2020-02-19
@xibir

An associative array might work.

declare -A array
array[str1]=value1
array[str2]=value2

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question