0

I am trying to extract the version of fortran compiler using ifort -v command and then grep it check for version.

However this does not work.

%ifort -v
ifort version 16.0.1
%ifort -v | grep "version"
ifort version 16.0.1
%ifort -v | grep "xyz"
ifort version 16.0.1

It appears as if the output is getting printed irrespective of my pattern. So to test it out I tried the following redirection to null and it still printed. It seems likes the output is not going to the stdout.

%ifort -v > /dev/null
ifort version 16.0.1


%ifort -v 2>/dev/null
ifort: error #10236: file not found: '2'
ifort version 16.0.1

Is it possible that the information i see in shell is actually being written by a different process than the current executing ifort command and thats the reason I am unable to capture it? How can I capture this and grep it?

ashish g
  • 429
  • 1
  • 7
  • 16

1 Answers1

0

Apparently the ifort -v writes to stderr. On bash redirecting stderr to stdout helps with that. The version could be obtained then for example using ifort -v 2>&1 | awk '{ print $2}'.

It looks like it is not trivial to redirect stderr to stdout on (t)csh and that csh family of shells is not well suited for scripting.

Community
  • 1
  • 1
Michal
  • 2,353
  • 1
  • 15
  • 18