鉴于echo "$varA"
:
Astringline1
Astringline2
Astringline3
和echo "$varB"
:
Bstringline1
Bstringline2
Bstringline3
我想获得:
Astringline1,Bstringline1
Astringline2,Bstringline2
Astringline3,Bstringline3
echo "$varA,$varB"
产生:
Astringline1
Astringline2
Astringline3,Bstringline1
Bstringline2
Bstringline3
答案 0 :(得分:3)
您可以使用paste
命令:
varA=$'Astringline1\nAstringline2\nAstringline3'
varB=$'Bstringline1\nBstringline2\nBstringline3'
paste -d, <(echo "$varA") <(echo "$varB")
Astringline1,Bstringline1
Astringline2,Bstringline2
Astringline3,Bstringline3