Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pipeline doesn't seem to have any effect in Bash

Tags:

python

bash

Anyone can explain me why this

python -V | awk '{print $2}'

returns this

Python 2.7.5                             

instead of

2.7.5

What to do to return only the version number without "Python " ?

like image 583
gr68 Avatar asked Nov 22 '19 09:11

gr68


1 Answers

If you run

python -V >/dev/null

you will notice that you still get output! Apparently, python -V prints its output to stderr, not to stdout.

In a bourne-like shell, this should work:

python -V 2>&1 | awk '{print $2}'
like image 104
Ture Pålsson Avatar answered Sep 27 '22 23:09

Ture Pålsson