Ignore lines in Shell Script

Hi,

I have a shell script, which reads a *.txt file - line by line. In this text file, I have some lines beginning with "#" that I want to ignore :

MY_FILE

 
#blah blah blah 1
blah blah blah 2
blah blah blah 3
#blah blah blah 4

I want my script to read only the following lines and process them:

 
blah blah blah 2
blah blah blah 3

Is there a way to incorporate this in my shell script?

 
#!/bin/bash
MY_FILE=$1
 
[ $# -eq 0 ] && { echo "Usage: $0 <filename>"; exit 1; }
 
while read line 
do
.......
.......
......
.....
....
done <  "$MY_FILE"

Check if the first character is # and if so, ignore the line.

while read LINE
do
        [ "${LINE:0:1}" = "#" ] && continue

        ...
done

This syntax should work in bash and ksh.

Thanks,

Works like a charm!

Alternatively you could strip out lines starting with a pound sign before feeding them to the while loop:

#!/bin/bash

MY_FILE=$1

grep -v "^#" $MY_FILE | while read LINE
do
  echo $LINE
done

exit 0