The tag has no wiki summary.

learn more… | top users | synonyms

3
votes
2answers
69 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
32 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
46 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) ...
2
votes
2answers
80 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}' ...
3
votes
3answers
135 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 ...
5
votes
1answer
75 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: ...
5
votes
2answers
386 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 ...
8
votes
2answers
189 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
142 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
176 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
116 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
133 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
62 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
161 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
190 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
439 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
821 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
131 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
2answers
47 views

How can I use tee to print the input stream?

I have a pipe line that looks like this: cat myfile | awk '$3 > 0 { print $1, $2 * $3 }' | tee >(printf) | perl myscript.pl I would like to print the input to my Perl script using tee. How ...
11
votes
2answers
224 views

Output order with process substitution

This is what I usually do to run grep and wc on a file without having to scan it twice <file.txt tee >(grep LITERAL) >(wc -l) >/dev/null However, this yields EXEC LITERAL 32 ...
0
votes
1answer
98 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
481 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
353 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 $ ...
2
votes
2answers
433 views

Creating temp file vs process substituion vs variable expansion?

If I am doing something like creating temporary file some process generating output > temp_file cat temp_file process substitution: cat <(some process generating output) another way : ...
1
vote
2answers
232 views

How to run chrome from command line by using process substitution?

I am using the following command without success - $ google-chrome <(grep "simple" SimpleDoc.txt) If I simply do a grep, I get - $ grep "simple" SimpleDoc.txt Very simple doc that contains ...
4
votes
1answer
153 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 ...
0
votes
0answers
85 views

Issues with process substitution

I am quite new to Linux and currently I am using Cygwin on my Windows machine. My problem is I made a script to automate my analytics work and used process substitution in it and it worked fine when ...
2
votes
2answers
477 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
243 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
603 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: ...
7
votes
3answers
269 views

When was process substitution first introduced?

I'm curios to know how long process substitution has been around. What shell first had it? When did it get added to other shells?
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 ...
15
votes
1answer
972 views

In zsh, difference between cat <(cat) vs cat | cat vs cat =(cat)?

As a zsh/process substitution noob, I expected cat <(cat) and cat | cat to do the same thing: copy lines from stdin to stdout. My understanding was that both would execute a cat in a subshell, ...
2
votes
1answer
291 views

password problem when feeding a remote file into diff

When I want to compare a local file with a remote file, any of these usually works: $ ssh remote cat file | diff file - $ diff file <(ssh remote cat file) However, sometimes (especially when the ...
5
votes
1answer
527 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
804 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 ...
20
votes
4answers
3k views

Process substitution and pipe

I was wondering how to understand the following: Piping the stdout of a command into the stdin of another is a powerful technique. But, what if you need to pipe the stdout of multiple ...