Pythonプログラミング言語でstdin(標準入力)を取得する方法について紹介します。
python -c 'import sys; print sys.stdin.read()'
e.g.
echo "hogefuga" | python -c 'import re,sys; print re.sub(r"hoge", "", sys.stdin.read())'
yuis@conoha:~$ seq 3 | python -c 'import re,sys; print sys.stdin.read() + "!!"'
1
2
3
!!
##
python -c 'import re,sys; print re.sub(r".*__restrictStdout__", "", sys.stdin.read())'
python -c 'import re,sys; print re.sub(r".*__restrictStdout__", "", sys.stdin.read(), flags=re.MULTILINE)'
python -c 'import re,sys; print re.sub(".*__restrictStdout__", "", sys.stdin.read(), flags=re.MULTILINE)'
perl -pe 'BEGIN{undef $/;} s/.*__restrictStdout__//smg' | perl -pe "chomp"