Why do I have to type ctrl-d twice? [duplicate]
This question already has answers here : Closed 5 years ago . Why do I have to press Ctrl+D twice to close stdin? (5 answers) For my own amusement, I've cooked up a python script that allows me to use python for bash one-liners; Supply a python generator expression; and the script iterates over it. Here's the script: DEFAULT_MODULES = ['os', 're', 'sys'] _g = {} for m in DEFAULT_MODULES: _g[m] = __import__(m) import sys sys.stdout.writelines(eval(sys.argv[1], _g)) And here's how you might use it. $ groups | python pype.py '(l.upper() for l in sys.stdin)' DBORNSIDE $ For the intended use, it