ArunJTS
ArunJTS

Reputation: 264

Conflict in GCC version display

In Linux machine, multiple versions of GCC are currently installed. To find out the current GCC version the below command is executed.

$ gcc --version

It displayed,
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4)

When the command 'gcc --version' is executed through a shell script, it is displaying a different gcc version.

The script content:

VERSION=$(gcc --version)
echo ${VERSION}

The display is, gcc (GCC) 4.8.2 Copyright (C) 2013 Free Software Foundation, Inc.

If the same shell contents are executed on command line it is showing different version of GCC.

$VERSION=$(gcc --version)
$echo ${VERSION}

It shows,
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4)

For the same command, it is displaying two different version of GCC, strangely. What could be cause of conflict?

Upvotes: 0

Views: 434

Answers (1)

Lee Duhem
Lee Duhem

Reputation: 15121

It is very possible that your current shell and your script using different setting of PATH. If you put a echo $PATH before both your gcc --version command, you will see the difference.

Upvotes: 1

Related Questions