2 ms·
Which is surprising since "research" here means pasting it into a terminal... Maybe they meant `cat file.txt | while ...`? Even then, you never want to do that
by ben509 8y ago
Which is surprising since "research" here means pasting it into a terminal...
Maybe they meant `cat file.txt | while ...`? Even then, you never want to do that when you're reading because elements of a pipeline are run in subshells. The usual idiom is:
while cond; do
thing
done < input > output
It's also the problem with cheatsheets: the underlying idea in bash is that compound statements are like mini programs, so they have file handles that can be redirected. That doesn't come through a cheatsheet very well.