The reason the linked example looks like this:
wc <(cat /usr/share/dict/linux.words)
And the mapfile answer looks like this:
mapfile -t array < <(./inner.sh)
Is because of the difference in the wc
and mapfile
commands and how the substituted process needs to be given to command.
As anishsane says the expansion of <(command)
is a filename and can be used anywhere a filename can be used.
wc
takes filenames as arguments so it can be used directly as an argument.
mapfile
reads from standard input so to get it to read from a specific file you use you redirect standard input from the file </path/to/somefile
but as I just said the expansion of <(command)
is a filename so you can use that in the input redirection.
However, you cannot just concat the two bits directly (the way you can with a file name/path) because <<
is also a valid shell construct (a here document) and that would be ambiguous to the shell. So to avoid that you need to space out the two <
characters and end up with < <(command)
(which is analogous to < file
which is perfectly legal).