Questions tagged [process-substitution]

Process substitution a form of inter-process communication that allows the input or output of a command to appear as a file (such as: `<(cmd)` or `>(cmd)`).

17 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
3
votes
1answer
62 views

Run asynchronous tasks and retrieve their exit code and output in bash

I have to run a bunch of bash commands asynchronously and as soon as one finishes, I need to perform actions according to its exit code and output. Note that I can't predict how for long any of these ...
3
votes
2answers
438 views

How to detect an error using process substitution

This question is similar to the following link, but focused on using the command line (bash shell). Using a simple example, when doing the following command: $ cat <(date); echo $? Fri Jul 7 21:...
2
votes
1answer
106 views

concurrent processing in bash using process expansion, and redirection

Apart from possible races that have to be controlled by using proper synchronisation, it's possible in bash to feed a data source concurrently into multiple pipelines and collect all their outputs ...
1
vote
0answers
25 views

How to use diff3 with text arguments instead of file paths?

I want to use diff3 with text arguments instead of file paths. For example, diff3 some_files/mine.txt some_files/older.txt ~/Downloads/yours.txt works as expected. However, I've been trying to achieve ...
1
vote
0answers
95 views

Using a here-doc with trailing backslashes inside a process substitution in bash

This: cat <<EOF one two three EOF Prints: one two three And this: cat <<EOF one \\ two \\ three EOF Prints: one \ two \ three But while this: cat <( cat <<EOF one two ...
1
vote
0answers
76 views

GPG error: “do_plaintext: wrote X bytes but expected Y bytes”

I'm having trouble using gpg when I use the <() syntax for process substitution. Here is a minimal-working example of my problem: $ gpg2 -c -o out.gpg <(head -c 73729 /dev/zero) gpg: ...
1
vote
0answers
181 views

process substitution with <(gunzip …) fails

The following code returns: syntax error near ( #!/bin/bash myprogram -i <(gunzip -c file.gz) -j <(gunzip -c file2.gz) It seems it doesn't like brackets. How can I make this script work? If I ...
1
vote
1answer
468 views

Bash Process Substitution in exec line, some commands stopped working

So I have a bash command using process substitution in an exec line that stopped working recently, and it boils down to this example: Contents of script.sh: #!/bin/bash ls -l "$1" >/tmp/out ...
0
votes
0answers
46 views

bash: how to pass variables to a loop within a process substitution

How do you pass variable values within a process substitution to a loop within that process substitution? I'm reading a csv file into an associative array, and while reading each line, I would like ...
0
votes
0answers
42 views

Process substitution doesn't work with diff and node

I'm trying to compare the output of my fizzbuzz.js program: for (let i = 1; i <= 100; i++) { let out = ""; if (i % 3 == 0) out += "Fizz"; if (i % 5 == 0) out += "Buzz"; if (i % 3 &&...
0
votes
1answer
15 views

Process substitution to script in order to monitor iotop

I am actively trying to get the output of the iotop for monitoring. As you know, the iotop is interactive, meaning that once started, it'll provide live updates on disk usage on the system. I'm ...
0
votes
0answers
54 views

Write stdout to a temp file using command line

Say for example we wanted to write the env from the host to Docker container, one way would be to use a temp file: env > env_file && docker run --env-file env_file image_name to avoid a ...
0
votes
0answers
56 views

How to pass to ssh the key stored in a shell environment variable?

Presumably ssh tries to access the fd several times, but the fd is destroyed after it has been read the very first time: # ssh -i <(echo $KEY) user@example.com Warning: Identity file /dev/fd/11 ...
0
votes
0answers
37 views

Process substitution of commands on separate lines of a string

I have a variable, COMMANDS, that contains a list of newline-separated commands (I know for example in this case that there will never be newlines, but they could be separated by NUL). For example, ...
0
votes
0answers
116 views

Bash Process Substitution Hangs When Listing Bindings

TLDR: cat <(INPUTRC=/dev/null bash -c 'bind -pm emacs') # freezes # I can't use this because I need to pipe the output of the bind cat <(INPUTRC=/dev/null bash -c 'bind -pm emacs' &) # ...
0
votes
1answer
349 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 ...
-1
votes
0answers
17 views

source script with process substitution in the background

Is there a way to source a script, via a background process? something like: (source <(curl $some_url)) & that shouldn't work at all. the only way I would know how to do it would be: (curl $...