8
votes
2answers
135 views

Bash: process substitution and stdin

The following line is obvious: echo "bla" | foo | bar But does the ones below do the same? echo "bla" | bar <(foo) echo "bla" | bar < <(foo) Which of the foo and bar read "bla" from ...
1
vote
2answers
95 views

Process substitution with input redirection

I am trying to understand input redirection in combination with process substituation. I am using bash 3 An example with tr is the following $ tr "o" "a" <(echo "Foo") tr: extra operand ...
7
votes
2answers
145 views

How to combine Bash's process substitution with HERE-document?

In Bash version 4.2.47(1)-release when I try to catenate formatted text that comes from a HERE-dcoument like so: cat <(fmt --width=10 <<FOOBAR (I want the surrounding parentheses to be part ...
5
votes
1answer
96 views

What are the difference between those four commands (fifo, process substitution, redirection…)

My goal is to create a simple echo server using nc and a single fifo. I'm not looking for the best way to do it, I'm merely trying to understand the semantics of the following commands (when does fork ...
2
votes
2answers
96 views

Process substitution with tee and paste

I'm trying to pipe a command through the output of two other commands and then merge the results of the two process substitutions. An example that gets me close is: command | tee >(sed -rn ...
1
vote
2answers
56 views

What fd's are used when doing diff <(cat old) <(cat new)?

If I do: diff <(cat old) <(cat new) Hoe does that work internally for the diff program? And how I do the same trick with a bash script?
7
votes
1answer
134 views

How do I capture the exit code / handle errors correctly when using process substitution?

I have a script that parses file names into an array using the following method taken from a Q&A on SO: unset ARGS ARGID="1" while IFS= read -r -d $'\0' FILE; do ARGS[ARGID++]="$FILE" done ...
3
votes
1answer
141 views

Performance differences between pipelines and process substitution

I tend to use pipelines in my bash scripts over process substitution in most situations, especially in cases of using multiple sets of commands as it seems more readable to do ... | ... | ... over ... ...
5
votes
2answers
364 views

How process substitution is implemented in bash?

I was researching the other question, when I realized I don't understand what's happening under the hood, what are those /dev/fd/* files and how come child processes can open them.
4
votes
2answers
563 views

Process substitution from curl to bash as root

I'm trying to run a script from URL as root with this command: sudo bash <(curl -s http://copy.com/gLVZIqUubzcS/popcorn) But I'm getting this error: bash: /dev/fd/63: Aucun fichier ou dossier ...
0
votes
0answers
112 views

Gnuplot and process-substitution

I have a log file where I need to cut out two values at different positions. these are: time and dQ in my file. The main problem is the paste I think. cause the other utilities work pretty well on ...
0
votes
1answer
91 views

Process substitution over ssh with sudo in Bash shell

What is the proper way to do something like this: diff <( ssh -t myuser@hosta 'sudo httpd -M') <(httpd -M) When I want to compare the output of the 2 commands, the first on a remote host the ...
0
votes
1answer
369 views

Occasional error from bash on AIX: Interrupted system call

I am experiencing problems with process substitution in bash on AIX It happens very rarely, apparently only when the server is loaded. An example error message is: line 9: /tmp//sh-np-7841523: ...
4
votes
1answer
307 views

Why doesn't the process substitution <() work with ssh -F

I have some vagrant virtual machines. To log into them I issue the vagrant ssh command. I want to log into them using regular ssh command. The vagrant ssh-config outputs the suitable config file $ ...
4
votes
1answer
141 views

Diff the output of the last two commands

I frequently find myself doing something like the following: $ big long command 1 $ big long command 2 $ diff -u <(big long command 1) <(big long command 2) How can I get the shell (bash in ...
2
votes
2answers
442 views

How to open process substituted file from php?

Here's what I tried to do myself: $ type 1.sh #!/bin/bash -eu php -r 'var_dump(file_get_contents($_SERVER["argv"][1]));' -- <(echo 1) $ ./1.sh PHP Warning: file_get_contents(/dev/fd/63): failed ...
5
votes
2answers
224 views

Combining multiple process substitution

Suppose you tried something like this: $ paste ../data/file-{A,B,C}.dat and realize that you want to sort each file (numerically, let's suppose) before pasting. Then, using process substitution, ...
2
votes
1answer
526 views

How to wait for a subprocess used for I/O redirection?

Consider the following snippet of Bash script: exec 3> >(sleep 1; echo "$BASHPID: here") do-something-interesting exec 3>&- wait $! echo "$BASHPID: there" When executed, it produces: ...
4
votes
3answers
2k views

How do I use tee to redirect to grep

I don't have much experience of using tee, so I hope this is not very basic. After viewing one of the answers to this question I came across a strange beheviour with tee. In order for me to output ...
5
votes
1answer
492 views

Pipes vs process substitution

While trying the cat "$@" trick to read from either standard input or given files, it turned out that pipe and process substitution handle a missing trailing newline differently: printf %s foo > ...
3
votes
4answers
760 views

Bash Reuse Process Substitution File

I have a big script which takes a file as input and does various stuff with it. Here is a test version: echo "cat: $1" cat $1 echo "grep: $1" grep hello $1 echo "sed: $1" sed 's/hello/world/g' $1 I ...