How do I iterate through lines in an external file with shell? [duplicate]

One way would be:

while read NAME
do
    echo "$NAME"
done < names.txt

EDIT:
Note that the loop gets executed in a sub-shell, so any modified variables will be local, except if you declare them with declare outside the loop.

Dennis Williamson is right. Sorry, must have used piped constructs too often and got confused.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)