I have 2 variables containing the same number of information, here 1 line with n=3 columns (I mean separated by a space)
var1='abc def ghi'
var2='klm nop qrs'
I would like the output to be the concatenated result with one line and 3 columns, with the following pattern :
abcklm defnop ghiqrs
I tried with a $(paste <echo $var1) <(echo $var2) -d '')
But it does the same as $var1$var2
.
The pr -ms' ' $var1 $var2
doesn't work, it's like it is waiting for a file rather than a variable
paste -d "" <(tr ' ' '\n' <<<"$var1") <(tr ' ' '\n' <<<"$var2") | paste -sd " "
Documentation:
tr
and paste
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.