Avoiding some files inside a loop

In my script I need to loop around some files like below
example files are
fa.info.abcd
fa.info.bxde
fa.info.cdas
------

  
for test_data in fa.info.*
do
 # Some text appending logic applied 
 # Copy to another directory
done  

Now I need to discard some files while looping around
for example if a files of below comes inside the loop i should avoid them and go to the next file
fa.info.ctye
fa.info.aicq
fa.info.auev
------
What logic/command is used to discard some files inside the loop !!
Thank You

Is this a homework assignment?

 
for test_data in fa.info.*
do
temp=`echo "$test_data"|grep -v 'abcd|bxde|cdas'`
#use temp variable instead of test_data
done

you got to replace 'abcd|bxde|cdas' with a logic which defines or recognize last 4 chars of your files then assign the result to another var (i used temp here). and use that variable then on.

Thank You Gaurav,

When i tried like below, I'm getting 'ac' as output . But my requirement is
'ac' should be avoided .

$ echo 'ac' |grep -v 'abc|ac'
ac

Please suggest me in this. This is not Home Work. This is my requirement

Thanks

Use the E flag so that grep can handle properly the pipe between the single quotes (logical 'OR') :

$ echo 'ac' |grep -vE 'abc|ac'
$

Thank You for the reply

I got an error when i tried the same .
I'm using KSH

$ echo 'ac' |grep -vE 'abc|ac'
grep: illegal option -- E

Thank you

Try egrep or grep -v "ab\?c"

Works fine for me :).

gacanepa@centos /home/gacanepa: echo 'ac' | grep -vE 'abc|ac'
gacanepa@centos /home/gacanepa: echo 'ac' | grep -vE 'abc'
ac
gacanepa@centos /home/gacanepa: echo $SHELL
/usr/bin/ksh

Not all grep's support -E, such as the standard one on Solaris, for example. But egrep is available, and /usr/xpg4/bin/grep does support -E

Also, the shell has nothing to do with it.

That seems to me an unnecessarily inefficient approach, if the patterns can be easily matched with sh pattern matching notation (aka file globbing):

for fname in fa.info.*; do
    case $fname in
        *.ext1 | *.ext2 | *.ext3 ) continue ;;
    esac
   # Rest of loop logic
done

Regards,
Alister