rhel_major=$(grep -Eoh [0-9]+\.[0-9]+ /etc/{issue,*release} | head -1 | awk -F'.' '{ print $$1 }')rhel_minor=$(grep -Eoh [0-9]+\.[0-9]+ /etc/{issue,*release} | head -1 | awk -F'.' '{ print $$2 }')rhel_release_code=$(echo $$(($(rhel_major) << 8 | $(rhel_minor))))For rhel_release_code I get a syntax error rhel_release_code=$(echo $$(($(rhel_major) << 8 | $(rhel_minor))))-bash: command substitution: line 1: syntax error near unexpected token `('-bash: command substitution: line 1: `echo $$(($(rhel_major) << 8 | $(rhel_minor)))'Any idea why it throws that error?
syntax error near unexpected token `('
shell script
bash throws an error because it's not valid shell code. (It's also not valid awk code.)Try thisrhel_major=$(grep -Eoh '[0-9]+\.[0-9]+' /etc/{issue,*release} | awk -F'.' '{ print $1; exit }')rhel_minor=$(grep -Eoh '[0-9]+\.[0-9]+' /etc/{issue,*release} | awk -F'.' '{ print $2; exit }')rhel_release_code=$((rhel_major << 8 | rhel_minor))If you don't actually want the $rhel_major and $rhel_minor values you could calculate $rhel_release directly in one step using awk.