files and files permissions

m trying to write a script that lists the files in the directory but
it should mask files if someone is searching for them,ownership rights and have access rights

What do you mean 'if someone is searching for them'?

Do you mean that when an ordinary user executes a command like

ls -l

the output does not have ownership or permissions?

Or just within this script?

You don't need individual permissions for each file, just set directory permissions for the parent directory. With the right permissions, only owners can read and / or write to the directory, and the same for groups. To keep the 'world' out, set 'other' to '0' (zero).

i mean within the script