When using awk in CentOS 7, the number is the 4th item instead of the 3rd. To remediate this instead use a regular expression to match on the whole string and ensure a period doesn't precede 6 or 7. However implementing the Perl regex engine with grep -P to use a negative lookbehind to make sure we don't match against 6 or 7 if it is preceded by a period.
Does match:
CentOS Linux release 6.6.8
CentOS Linux release 7.0.1406
CentOS Linux 6.4
Doesn't match:
CentOS Linux release 5.7
CentOS Linux 5.6.8
When using awk in CentOS 7, the number is the 4th item instead of the 3rd. To remediate this instead use a regular expression to match on the whole string and ensure a period doesn't precede 6 or 7. However implementing the Perl regex engine with
grep -P
to use a negative lookbehind to make sure we don't match against 6 or 7 if it is preceded by a period.Does match: CentOS Linux release 6.6.8 CentOS Linux release 7.0.1406 CentOS Linux 6.4
Doesn't match: CentOS Linux release 5.7 CentOS Linux 5.6.8