0

Hello I have a few variables with information, for example:

$names=

Tomer      
Jacob      
Adam 

$Age:
25 
27 
28

$Country:
USA
Spain
Brazil   

I would like to merge and print these details in a form that each lines presents a person with all his details Wanted OUPUT:
Tomer 25 USA
Jacob 27 Spain
Adam 28 Brazil

i have tried to do something like this

for i in {1..$NumberOfLines} 
do 
echo $Names | head -$((i))
echo $Ages | head -$((i))
echo $Country | head -$((i))
done

of ocurse its not working

  • You seem to be looking for the `paste` command in some form or another, but your exposition is rather unclear. If the text is in variables, Bash lets you do something like `paste <(echo "$Names") <(echo "$Ages") <(echo "$Country")` but this seems quite unnatural; usually it would be more convenient if these values came from files. – tripleee Dec 15 '21 at 08:00
  • Perhaps see also https://stackoverflow.com/questions/65538947/counting-lines-or-enumerating-line-numbers-so-i-can-loop-over-them-why-is-this – tripleee Dec 15 '21 at 08:01
  • Please write syntactically correct assignment statements for your variables. If you just sketch the content, I don't even know whether you are using scalars or arrays to hold this information. – user1934428 Dec 15 '21 at 08:13

0 Answers0