==== read from stdin ==== tags | read lines from stdin $ cat count_lines.py import sys data = sys.stdin.readlines() print("Counted", len(data), "lines.") $ cat count_lines.py | python count_lines.py Counted 3 lines. Ref:- * https://stackoverflow.com/a/1450396 * Used this technique to answer https://unix.stackexchange.com/questions/743855/convert-only-all-uppercase-lines-to-lower-case