Preserving leading white space while reading>>writing a file line by line in bash
As others have pointed out, using cat or awk instead of a read-echo loop is a much better way to do this — avoids the whitespace-trimming problem (and a couple of others you haven’t stumbled upon), runs faster, and at least with cat, is simply cleaner code. Nonetheless, I’d like to take a stab at … Read more