Home > Net >  How to execute each line separately
How to execute each line separately

Time:12-06

I have for example a text with

2 3
4 5

and when I want to grep the first word in

$firstword

I get

2
4

and it is the same with the second word. and when I do

echo $firstword $secondword

I get: 2 3 4 5

So my question is how can I still have

2 3
4 5 

when i put them in a variabele and then use echo. Thank you

CodePudding user response:

echo by itself is not capable. paste works here

paste -d ' ' <(echo "$firstword") <(echo "$secondword")

The Process Substitutions make paste read from echo "$firstword" and echo "$secondword" as if they were files. Take note, the quotes are required.

  •  Tags:  
  • bash
  • Related