script to compare files

HI

i wil get input from sql query and that too i can get a list o f files or just one.

i have to pick up a file from another directory which hads prefix to this prefix.x.x.x.x.x. And we have to discard prefix and use that file name.

we have to compare this file name(no need to worry about fields) just file name only with input file if they are match the we have to pick this file (not from input) and write to a file if it doesnt match then distict of input files.we have to check each and every file from input

for ex input file will be like x.x.x.x.x
otherfile will be like prefi.x.x.x.x.x.x

can any one help to write in KSH
Thanks in Advance