paste two outputs without using temp files

geermu
geermu used Ask the Experts™
on
Current code
cmd1 > output1; cmd2 > output2; paste output1 output2 > output
rm output1 output2

Is it possibe to complish same thing without introducing the intermiate files.

Thanks.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2013
Top Expert 2013

Commented:
cmd1 > output1
cmd2 >> output1
Commented:
cmd1 >output1; cmd2 | paste output1 - >output

I can only get it down to 1 intermediate file...  if I stay in shell code.

Author

Commented:
one intermediate is better than 2.
I will accpet (or partially accept) it, unless some other better solution
Thanks lot.
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Commented:
are you stuck with a shell script?  Do you have perl?  It would take a few lines of perl to do something similar with no intermediate files.

Author

Commented:
Not much experienc with perl.
awk may be possible?
Top Expert 2007

Commented:
You should be able to do

(cmd1;cmd2) | paste - - >output
Top Expert 2007

Commented:
Ignore my last comment, the order is not want you want. kevinu's solution is the closest you can get.

Commented:
I don't belive awk can do it.
>> I don't belive awk can do it.
why not? awk is not just for one liners.
an example



awk 'BEGIN{
    cmd1="ls"
    cmd2="ls"
    while((  cmd1 | getline line)>0) {        
        a[++f]=line
    }
    close(cmd1)
    while((  cmd2 | getline l)>0){
        print l "-->" a[++g]    
    }
    close(cmd2)   
}
'

Open in new window

Author

Commented:
Thanks. I splited the points

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial