-1

I need to get the version number of a program from the following output:

~$ pyrcc5 -version
pyrcc5 v5.15.0
~$

Now I thought cut could do the job:

~$ pyrcc5 -version | cut -f2 -d"v"
pyrcc5 v5.15.0

~$

But it doesn't cut away anything ?!?

~$ echo $(pyrcc5 -version) | cut -f2 -d"v"
pyrcc5 v5.15.0

~$

Even worse … Expected output would be

5.15.0
Cyrus
  • 84,225
  • 14
  • 89
  • 153
TheEagle
  • 5,808
  • 3
  • 11
  • 39

1 Answers1

3

pyrcc5 is printing the version string to stderr, not stdout. Try pyrcc5 -version 2>&1 | cut -dv -f2.

hobbs
  • 223,387
  • 19
  • 210
  • 288