I am using Linux Mint 18.3 Mate 64 bit
I have 4 Bash arrays as follows:
[CODE]name=(Bob Bill Steve Richard Janet)
hair=(brown grey grey brunette blonde)
eyes=(blue brown brown green hazel)
build=(average slim average big average)[CODE]
I need it printed out in the following format (each sentence has its own line but double spaced and only one space between each word):
${name[@]} has ${hair[@]} hair and ${eyes[@]} eyes and ${build[@]} build.
Output example needed:
Bob has brown hair and blue eyes and average build.
Bill has grey hair and brown eyes and slim build.
Steve has grey hair and brown eyes and average build.
Richard has brunette hair and green eyes and big build.
Janet has blonde hair and hazel eyes and average build.
I would like this to be executed in one command in Bash script if possible.
I have tried this :
Code:
paste <(printf "%s\n" "${name[@]} has") <(printf "%s\n" "${hair[@]} hair and" ) <(printf "%s\n" "${eyes[@]} eyes and") <(printf "%s\n" "${build[@]} build.") > profile.txt
awk {$1=$1}, OFS=" " profile.txt
but can't seem to get it right.
Any and all suggestions are greatly appreciated.
Thank you
cogiz