Much of the *nix world revolves around the
POSIX standard; a large, complex specification that defines a minimally-compatible operating system. Most *nix-style OSes try to conform to this standard at least in part, and so should have at least a basic level of compatibility. Above and beyond POSIX, however, individual operating systems are free to add or alter their features and behavior as they will, just as long as the POSIX behavior is still available when needed.
For example, POSIX specifies that the system must include a basic shell (/bin/sh) that supports certain features and syntax, and a set of core utilities such as
grep,
sed, and
awk. So on Linux you have
bash, and on some other systems you might be using
ksh or another shell.
ksh and
bash are both POSIX compatible, and have many other syntax similarities, but there are also many differences as well. Similarly BSD has its own home-grown version of
grep and
sed, as does AIX, among others, and Linux uses versions written by the
GNU project (
bash is also a GNU program). These tools are again all broadly compatible at the POSIX level, but often also include features that go above and beyond the standard, which are not compatible. The
gnu coreutils in particular have been expanded far beyond POSIX and include many useful features not found elsewhere.
What it all boils down to is that if you stick with POSIX, you can be fairly guaranteed that what you use is cross-platform (or at least can be made to be with minimal effort), but outside of that you have to check the documentation for the platform in question.