Pipeline Doesn't Seem To Have Any Effect In 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
Solution 1:
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}'
Solution 2:
How about using pure python command itself(I need to format it with dots in between though)
python -c 'import sys; print sys.version_info[0],sys.version_info[1],sys.version_info[2]'
OR as per Chris's comment use:
python -c 'import sys; print(".".join(map(str, sys.version_info[:3])))'
Post a Comment for "Pipeline Doesn't Seem To Have Any Effect In Bash"