3 thoughts on “Iterate a Text File in Bash

  1. Actually, this is how not to do it — it starts a useless cat process and needs to store the whole file in memory. The right way to do it goes like this:

    while read line
    do
    echo $line
    done < FILE.TXT

  2. to iterate file lines is a a bad idea. Plus, the expansion aspect mentioned by @mklement0 (even though that probably can be circumvented by bringing in escaped quotes, which again makes things more complex and less readable). Egor Hans Nov 12 ’17 at 14:23

Leave a Reply

Your email address will not be published. Required fields are marked *