1

I want to check gcc version whether >= 9.1.

First, I type this shell:

$ gcc --version | grep gcc | awk '{print $3}'

I get following in my computer after I type above shell:

9.1.0

I know bash only can compare number of integer,

such as command "-gt".

I want to compare gcc which version >= 9.1 .

How do I do?

curlywei
  • 566
  • 4
  • 15

1 Answers1

-1

You need not to use grep with awk, awk could look for string and could do comparison too. Could you please try following.

gcc --version | awk '/gcc/ && ($3+0)>9.1{print "Version is greater than 9.1"}'
RavinderSingh13
  • 117,272
  • 11
  • 49
  • 86