Puzzling Bash syntax - loop redirection

Running the script through shellcheck.net I was told that the " output forcycle is findfragile." Fair enough, file names with spaces are always complicated.

Suggested replacement code (one of them anyway):

while IFS= read -r -d '' file
do
    #do stuff
done <   <(find . -name '*' -print0)

I am familiar with the operator <, which is used to enter text from a file into a command, and, obviously, the results from findare fed into a loop. Therefore, when I first saw this, I thought that he was the victim of some formatting problems and tried to "clear" the last line. But removing the space between < <led to syntax errors, like adding one in <(.

So what does the design < <(cmd)do? Sorry if this is a simple or redundant question, it is not easy to find these things!

+4
source share
2 answers

< redirect input as you say.

<( Replacement process .

Process substitution is supported on systems that support named pipes (FIFOs) or the / dev / fd method for naming open files. He takes the form

<(list)

or

>(list)

, FIFO /dev/fd. . a > (), . < (list), , , . , < > , .

, , .

<, document.

< (, .

+5

A while loop in bash . , . , , while, .

read find.


<(find ...) . find, <(...) , find. "" while (, , read) .

+3

Source: https://habr.com/ru/post/1616613/


All Articles