From charlesreid1

Revision as of 20:25, 23 April 2018 by Admin (talk | contribs) (Created page with "Here's the trick to using python as a one liner: <code>sys.stdin.read()</code> <pre> echo "zero one two three" | python -c 'import sys; print(sys.stdin.read().split(" ")[2])...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Here's the trick to using python as a one liner: sys.stdin.read()

echo "zero one two three" | python -c 'import sys; print(sys.stdin.read().split(" ")[2])

Above, we print sample output and pipe it to a python program..

The Python takes everything from stdin and reads it into a string, turns it into a list by splitting at spaces, and prints the third item in the list.