paste without temporary files in Unix

后端 未结 4 1620
一个人的身影
一个人的身影 2021-01-31 04:10

I\'m trying to use the Unix command paste, which is like a column-appending form of cat, and came across a puzzle I\'ve never known how to solve in Unix.

How can you use

相关标签:
4条回答
  • 2021-01-31 04:49

    Holy moly, I recent found out that in some instances, you can get your process substitution to work if you set the following inside of a bash script (should you need to):

    set +o posix

    http://www.linuxjournal.com/content/shell-process-redirection

    From link: "Process substitution is not a POSIX compliant feature and so it may have to be enabled via: set +o posix" I was stuck for many hours, until I had done this. Here's hoping that this additional tidbit will help.

    0 讨论(0)
  • 2021-01-31 04:53

    Works in all shells.

    {
    progA
    progB
    } | paste
    
    0 讨论(0)
  • 2021-01-31 04:54

    Use named pipes (FIFOs) like this:

    mkfifo fA
    mkfifo fB
    progA > fA &
    progB > fB &
    paste fA fB
    rm fA fB
    

    The process substitution for Bash does a similar thing transparently, so use this only if you have a different shell.

    0 讨论(0)
  • 2021-01-31 04:55

    You do not need temp files under bash, try this:

    paste <(./progA) <(./progB)
    

    See "Process Substitution" in the Bash manual.

    0 讨论(0)
提交回复
热议问题