change all materials with the same name?

Hello! I ask you a short question, what can I do so that in a script ONLY the materials with the same assigned name change to another one? (the other is a variable)
Thank you!

glassobject.renderer.materials = (GLASS) = damagetex;

You could iterate through all the materials assigned to the object and check their name like this:

        for(int i = 0; i < glassRenderer.materials.Length; i++)
        {
            if (glassRenderer.materials*.name == "Glass")*

{
glassRenderer.materials[0].mainTexture = damagetex;
}
}
I would use a GetComponent on the glassobject to store the renderer for easy access as glassRenderer