I saw the following example for reading a file in a bash script:
while read IP; do
${IPTABLES} -I INPUT -s "${IP}" -j DROP
done < <(cat "${BLACKLIST}")
but I'd have thought to do the following instead:
while read IP; do
${IPTABLES} -I INPUT -s "${IP}" -j DROP
done <${BLACKLIST}
Why would one use < <(cat
instead of simply <
? What is the right-est way to do this?
Second comment on this question gives good reason why using cat
is bad but RoseHosting.com seems pretty reputable and they suggest the code above that uses cat
. I'm thinking the < <(cat file)
looks like a weird way to cover up a bad practice. (here's another place it was pointed out cat
piping to a loop is bad)