Reading lines in a file and avoiding lines with # with Bash

To skip lines starting with #:

grep -v '^#' myfile | while read -r file ; do
    ...
done

Modify the grep command as needed to, for example, skip lines starting with whitespace and a # character.

Leave a Comment