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)`).

learn more… | top users | synonyms

1
vote
0answers
27 views

error:too many words `` in cat

I have a csv file that auto-generate with filename format yy-mm-dd_h. The csv file content: Status Filename 1 1A-W02_ws_r0_apr13_15_44.stdf 1 2A-W04_ws_r1_apr12_10_30.stdf 1 ...
1
vote
2answers
24 views

Failed to open config file '/dev/fd/63', error: No such file or directory for wpa_supplicant

When I do this: sudo wpa_supplicant -D nl80211,wext -i wlp4s0 -c <(wpa_passphrase "some ssid" "password") I get Successfully initialized wpa_supplicant Failed to open config file '/dev/fd/63', ...
3
votes
2answers
107 views

How do you implement process substitution (using a bash script) in a shell that doesn't have it?

I've seen Fish shell implement process substitution as a function: # === Fish shell lang: function psub mkfifo $the_pipe cat >$the_pipe & echo $the_pipe # remove pipe when bg job ...
4
votes
0answers
76 views

bash process substitution with temporary file

Some programs needs their files to be seekable, for example objdump does. $ objdump -D -b binary -m i8086 <(echo 0xea 0x5b 0xe0 0x00 0xf0|xxd -r -p) objdump: Warning: '/proc/self/fd/11' is not an ...
4
votes
1answer
63 views

File descriptors and redirect in bash

Can someone explain why this command works: gpg --enable-special-filenames --verify --batch \ <(curl -s https://www.gnupg.org/ftp/gcrypt/gnupg/gnupg-2.0.29.tar.bz2.sig) \ <(curl ...
2
votes
3answers
68 views

Processing a single file as both input and output throughout pipes [duplicate]

Good evening, I would like to filter a file's content with some piped commands and then write the result back to the same file. I know, I can't do that the way I wrote it. Hold on … This is the ...
1
vote
1answer
30 views

Scope of variables in a process substitution

I have a command which takes two arguments. Assume we want to create both arguments by process substitution: cat <(var=123; echo $var) <(echo $var) What has to be done, to make $var available ...
0
votes
2answers
172 views

Bash - Redirect output to a variable or file descriptor, then read from the variable or file descriptor

Here's an example of a bash script that redirects all output to a file (and shows output on the screen too): # writing to it exec > >(tee --ignore-interrupts ./log) exec 2>&1 echo "here ...
2
votes
2answers
60 views

Read a password securely from within process substitution?

Related: Securely feeding a program with a password How to read from stdin in process substitution? Process substitution and cat: can't read stdin I've read the above questions and I still ...
5
votes
2answers
62 views

Understanding i/o redirection in the context of _process substitution_

Running GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu). I don't really understand process substitution (ProcSub) from the perspective of a user interested in lifting the hood on i/o ...
2
votes
1answer
163 views

bash while/read loop behaves differently in a mips/musl/busybox based VM

On a musl/busybox based system running in qemu (mips), the script #!/usr/bin/bash printf '%s\n' "${BASH_VERSION}" > test.txt echo 'test.txt:' cat test.txt echo "No process substitution:" while ...
4
votes
1answer
119 views

Ctrl-c kills shell when pipeline is used in input redirection subshell

If I run a command like: cat <(echo 1 | pv) | pv cat <(echo 1 | pv) | less cat <(echo 1 | pv) | cat The command seems to run forever. Entering ^C (SIGINT) kills the entire shell instead ...
1
vote
2answers
86 views

cryptsetup: Attaching loopback device failed

I am using cryptsetup with detached header. For that I am using the --header parameter, to specify header file. I can open my device using: cryptsetup luksOpen /dev/sdb1 sdb1 --header LUKS-HEADER ...
5
votes
2answers
674 views

Running remote command with ssh getting “bash: /dev/fd/63: No such file or directory”

I have /root/test.sh on a remote server, which has the following content: #!/bin/bash date On the remote server, I get the following output: # ./test.sh Fri Dec 18 07:41:10 EST 2015 # bash ...
1
vote
1answer
40 views

Find files and send to a temp file

Vim does support a nice option to accept a file with list of files that are then opened in a Quickfix list. Rough example, I find all files in ~ that are smaller than 1KB and pass this to Vim: find ~ ...
1
vote
1answer
75 views

How to read from stdin in process substitution? [duplicate]

I would like to send stdout to multiple commands, however I'm not sure how do I read from standard input within process substitution? My attempts: $ echo foo >(cat /dev/stdin) >(cat ...
2
votes
1answer
61 views

Process substitution and cat: can't read stdin

The process substitution <(cat) doesn't work. Why? head <(cat) cat: -: Input/output error I can use an extra file descriptor, but I don't understand why the above doesn't work. # Using file ...
2
votes
2answers
52 views

Insert result of command into an executable (one command) [duplicate]

Is it possible to insert the result of a command (or even a chain of commands) into an executable in one command? Something like this: ./a.out < echo 0 Or is it necessary to do this: echo 0 ...
6
votes
0answers
110 views

Why does OS X `install` errors on redirected input when the same version of `install` on linux works fine?

I would like to use install command in order to create a new executable file with pre-populated content (e.g. with single pwd command in it). So I've extended this example which creates a new empty ...
4
votes
2answers
329 views

Putting process substituted file descriptor into variable

I have long command roughly this: $ command-outer "long command which references a file here: filename1, and another file reference here: filename2" The files are the output of another command. So ...
33
votes
2answers
2k views

Why does `sort <(ls -l)` work but `sort < (ls -l)` fail?

Today I'm learning something about fifo with this article: Introduction to Named Pipes, which mentions cat <(ls -l). I did some experiments by using sort < (ls -l), which pops out an error: ...
0
votes
1answer
48 views

Process substitution syntax. Forward/right bracket vs backward/left bracket

tldp lists two syntaxes for process substitution. >(command_list) and <(command_list) What is the difference, if any?
8
votes
2answers
229 views

bash: how to propagate errors in process substitution?

I want my shell scripts to fail whenever a command executed with them fails. Typically I do that with: set -e set -o pipefail (typically I add set -u also) The thing is that none of the above ...
2
votes
1answer
189 views

How to set pipe of process after process substitution in bash so that process continues after script ends?

How can I set up a process that has had its output redirected via process substitution so that it can survive after the parent script exits? I am trying to set up a Bash script to monitor the output ...
0
votes
1answer
124 views

How to catch first line of stdout from bash process substitution?

I am working with the following block of bash and it is not printing out the first line of expected output: exec 3< <(python3 -m http.server) while true; do read -t 2 line ...
1
vote
1answer
75 views

How to create dynamic process substitution based on the input (multiple FIFOs)?

I'm trying to create multiple process substitutions based on the output from the other command, however I'm not sure how I can achieve that. As sample scenario, I've given list of files: touch a.txt ...
8
votes
2answers
251 views

How bash treats “> >()”

While experimenting with output redirection and process substitution I stumbled upon the following command and its resulting output: me@elem:~$ echo foo > >(cat); echo bar bar me@elem:~$ ...
3
votes
1answer
57 views

Question about interactive detection in bash

I have a question about interactive detection in bash. The following script prints if it is called in interactive mode or not. $ cat int.sh #!/bin/bash if [ -t 0 ]; then echo "interactive" ...
7
votes
4answers
381 views

Split an input for different command and combine the result

I know how to combine the result of different command paste -t',' <(commanda) <(commandb) I know pipe same input to different command cat myfile | tee >(commanda) >(commandb) Now ...
0
votes
2answers
102 views

process substitution for opening a list of files with an application

I wish to use process substitution to direct a list of files (produced, for example, by ls or find) to a particular application for opening/viewing. While piping such a list to xargs is suitable for a ...
6
votes
2answers
279 views

Using process substitution to trick programs expecting files, with specific extensions as argument?

Here is my use case: the command line utility melt can accept a file name, with the extension .melt on the command line, and open it; as an example, this is a proper test_p.melt file: colour:blue ...
1
vote
1answer
118 views

“Sudo” prefixed command doesn't work; without sudo does.

I suspect this has been answered before, but I don't know what this is called, so I can't really search for it. How come this works : $ grep H=p <(udevadm info /dev/ttyUSB0) E: ...
2
votes
5answers
7k views

grep files from list

I am trying to run grep against a list of a few hundred files: $ head -n 3 <(cat files.txt) admin.php ajax/accept.php ajax/add_note.php However, even though I am grepping for a string that I ...
1
vote
2answers
232 views

How to use process substitution within a case statement without getting syntax errors?

I have a script loaded as a service in /etc/init.d/myfile When I try to start the service I get the error /etc/init.d/myservice: 21: /etc/init.d/myservice: Syntax error: "(" unexpected The issue ...
0
votes
1answer
47 views

Why doesn't this tee with process substitution produce the 1st and chosen lines? [duplicate]

What I want is printing the output the first line ( table head ) of ps aux and the grep result. After search, I come up with following. ps aux | tee >(head -1 > /dev/tty) | grep mongo But I ...
3
votes
2answers
396 views

Am I hitting a race condition in bash?

I have a script which compares the output of a command with the output of the same command as it was ran previously, it works most of the time, but every now and then it doesn't work as expected. ...
0
votes
1answer
47 views

Syntax of process substitution

I am really having some trouble understanding pipeline substitution. I have a program that I run with the make command that writes to stdout. What I want to be able to do is parse through the output ...
1
vote
2answers
216 views

Extracting list of patterns which are output of another command

I can extract list of patterns using following command, fgrep -A 1 -f patternlist.txt filename.fasta but, is there a way I can extract without creating another file (patternlist.txt in this case) ...
3
votes
2answers
4k views

syntax error near unexpected token `<'

I am writing a script to read the output of a command to variable a and b. This is the script #!/bin/bash read a b < <(awk '/Application Server/ && !seen[$7]++{printf "%s ", $7}' ...
6
votes
3answers
556 views

Dash equivalent of self-redirection of script output

In Bash you can redirect all future stdout output of the currently running script. For example with this script, exec > >(logger -t my-awesome-script) echo 1 echo 2 echo 3 This will end up in ...
9
votes
1answer
737 views

Why does BASH process substitution not work with some commands?

On occasion process substitution will not work as expected. Here is an example: Input: gcc <(echo 'int main(){return 0;}') Output: /dev/fd/63: file not recognized: Illegal seek collect2: ...
17
votes
2answers
4k views

Why does process substitution result in a file called /dev/fd/63 which is a pipe?

I am trying to understand named pipes in the context of this particular example. I type <(ls -l) in my terminal and get the output as, bash: /dev/fd/63: Permission denied. If I type cat <(ls ...
9
votes
2answers
598 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 ...
3
votes
2answers
789 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 ...
9
votes
3answers
770 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 ...
6
votes
1answer
222 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
691 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
88 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?
8
votes
3answers
502 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 ...
5
votes
1answer
653 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 ... ...