I have a variable named concat (result of a paste command between 2 variables). Concat is a multi-line variable containing strings:
strawberrie red
banana yellow
apple green
Result of typeset -p concat :
declare --concat ="strawberrie red
banana yellow
apple green"
I need to append at the beginning of each line of this variable another variable named type :
fruit
The result i need to get after an echo the variable array (edit : it is not an array but i called it like that)
fruit strawberrie red
fruit banana yellow
fruit apple green
I tried with sed but it didn't worked :
echo "$concat" | sed "/^/$type"
error returned is sed command not found (even if sed work)
array=$(sed '/^/$type')
just don't work
And i find many other solutions on internet but none of them worked for me (i don't know how to use sed properly so i guess i may had written not adapted options).
Which command i need to use to do that (and could you explain me the option you use in it so i dont paste it without learning) ?
Edit : This is the code i used to append the variable fruit to the variable concat and save in in the variable array (a string too) :
array=$(sed "s/^/$type /g" <<< "$concat")