Grep command to ignore line starting with hyphen

Hi,

I want to read a file line by line and exclude the lines that are beginning with special characters. The below code is working fine except when the line starts with hyphen (-) in the file.

for TEST in `cat $FILE | grep -E -v '#|/+' | awk '{FS=":"}NF > 0{print $1}'`
do
.
.
done

How should the grep statement be modified to ignore the line starting with hyphen?

Thanks
Srinraj

for TEST in `cat $FILE | grep -E -v '#|/+' | awk '{FS=":"}NF > 0{print $1}'`

The thing is that grep does not need cat.
grep pattern $FILE can read the file for itself.
awk does not need cat or grep. awk can exclude as well on its own.

awk '$0 !~ /pattern to exclude/ {action}' $FILE

As an example if you want to exclude all these character in the beginning of a line: `#/-+'

awk '$1 ~ /^[^-#/+]/' $FILE

Thanks for your quick response. My requirement is different.

The file contains text as follows.

#test
+abc
-xyz
real

The for loop has to read the file line by line and pass the string in each line to the do loop. While reading each line in the file, if the line starts with # or + or - that line should be ignored.

And still applies, if you care to continue using the same script model.

for TEST in $(awk '$1 ~ /^[^-#/+]/' "$FILE"); do
     something "$TEST"
done

However, the shell doesn't need awk or any external program in this case to do what you want.

while read line; do
   if [[ "$line" =~ ^[^-+#] ]]; then
        echo "Do something with $line"
   fi
done < "$FILE"

Is this a homework assignment?

Homework questions must be posted in the homework & coursework questions forum and must include a completely filled out homework template.