While two solutions were given, you may wonder why the original code didn't work.
Code:
if $(uname -a | grep el7); then
...
does the following:
- Run the command uname -a | grep el7
- Take the output of step 1 and substitute $(...) with it
- Execute the if
The output in step 2 looks like this:
Linux MACHINENAME KERNELVERSION .... Therefore, the
if condition in step 3 becomes
Code:
if Linux MACHINENAME KERNELVERSION ...
which results in a syntax error, since there is no command named
Linux.