Misunderstanding the purpose of a process substitution
3
votes
1
answer
280
views
I guess I'm missing some understanding on the use cases of a process substitution. My intuition was that a process substitution, of the form
<(COMMANDS)
would execute COMMANDS
and then feed the result of the program into whatever command it's a part of, so command1 <(command2)
would evaluate command2
and pass the result as the first argument into command1
.
I thought the following would've worked:
$ for i in <(cat list.txt); do echo $i; done
where list.txt
is a file containing a list of words (separated by newlines). When I run this, it simply outputs /dev/fd/63
, which I can only assume is like a temporary pathname to the output of the subshell created in the process substitution?
I thought the above would've worked, because it works fine when I write
$ for i in cat list.txt
; do echo $i; done
I've never seen this `
notation before, what does it mean exactly? And what understanding am I lacking about process substitutions?
Asked by user3002473
(193 rep)
Feb 9, 2018, 02:01 AM
Last activity: Jun 14, 2023, 04:09 PM
Last activity: Jun 14, 2023, 04:09 PM