LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 11-09-2012, 12:12 PM   #1
forumbaba
LQ Newbie
 
Registered: Aug 2011
Posts: 19

Rep: Reputation: Disabled
paste output of two commands


I am trying the following command but its not working:

paste < (awk '{ print $1 }' file1 | program1 ) < (awk '{ print $2 }' file2 | program2)
 
Old 11-09-2012, 05:29 PM   #2
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,970

Rep: Reputation: 848Reputation: 848Reputation: 848Reputation: 848Reputation: 848Reputation: 848Reputation: 848
Could you please explain, what you expected what the command would do. What are program1 and program2?

Markus
 
Old 11-09-2012, 10:17 PM   #3
forumbaba
LQ Newbie
 
Registered: Aug 2011
Posts: 19

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by markush View Post
Could you please explain, what you expected what the command would do. What are program1 and program2?

Markus
Hi,

I want to print the output of two independent commands on the same line side by side, for example:

If output of command one is "AAAA" and output of command two is "BBBB" then I want to produce an output such as:

AAAA BBBB

program1 and program2 are scripts that take input, perform some calculations and produce output.


Thanks

PS: when I use my earlier line I get the error: Missing name for redirect.
 
Old 11-09-2012, 10:29 PM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 1,421

Rep: Reputation: 597Reputation: 597Reputation: 597Reputation: 597Reputation: 597Reputation: 597
I can't replicate that same error message, but you need to lose the spaces between "<" and "(". The "<(" that introduces process substitution is a single token and must not be broken up.
 
1 members found this post helpful.
Old 11-10-2012, 01:47 PM   #5
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
I don't see that this question is any different from the topic you have running already here:

http://www.linuxquestions.org/questi...6/#post4825971


We usually want to keep conversations on the same topic together. So only create a new threads if your question is substantially different from the previous ones.


But yeah, to follow up on the above, bash's process substitution is a simplified, automated way to create a background fifo. In essence "<(..)" (no space) acts like a file that contains the output of the commands contained in it.

If needed, this can be then redirected as normal with another "<". e.g.:

Code:
$ tr ":" "-" < <( echo "foo:bar" )
foo-bar
Note that the space between the two "<" characters is necessary.

But for commands that can read from files directly, the extra redirection isn't needed:

Code:
$ cat <( echo "foo:bar" | tr ":" "-" )
foo-bar
 
  


Reply

Tags
awk, commands, output, paste


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CLI commands with(1) and console copy & paste? EricGalaxy Linux - Newbie 2 09-28-2011 09:16 PM
"Paste" output in Bash script not as expected... jb2011 Programming 15 05-19-2011 10:53 AM
copy/paste output from shell (not terminal) bluegospel Linux - Newbie 13 07-21-2010 01:37 PM
commands for output? jtek74 Linux - Newbie 13 08-29-2008 12:00 PM
how to use one commands output vkmgeek Linux - Newbie 3 09-15-2007 11:04 AM


All times are GMT -5. The time now is 05:25 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration