GLSL and Cross Platform

Hi, I just started learning the basics of Shaders and GLSL.

I learned that there are different GLSL versions based on different openGL versions.

And I’m curious if it would be possible to make one shader file to run on multiple platforms (e.g OSX and iOS)
As I checked, shadersES2 and shadersGL2 are pretty similar but shadersGL3 seemed to have some more deprecated variables.

So I googled, and I found a post regarding the cross-platform solution between openGL and GLES using preprocessor tricks.

But are shadersES2 and shadersGL2 really replaceable like the post?
I checked OF shader examples and some examples seemed to use different variable names.

As you can see, shadersES2 has texture2D whereas shadersGL2 has texture2DRect.
How different are they? Should I learn both if I want to make the cross platform shader files?

As I know you can’t run GL2 shaders on GLES2 devices, texture2DRect is not supported on ES2.