Commit | Line | Data |
---|---|---|
f4b7fb50 SBS |
1 | #!/usr/bin/env python3 |
2 | # Desc: Reads stdin | |
3 | # Input: stdin (consumes) | |
4 | # Output: stdout (newline delimited) | |
5 | # Example: echo -e "foo\nbar\n" | python3 this_script.py | |
6 | # Depends: Python 3.10.12 | |
7 | # Version: 0.0.1 | |
8 | ||
9 | import sys | |
10 | ||
11 | def read_stdin(): | |
12 | """Reads from stdin and outputs to stdout.""" | |
13 | lines = [] | |
14 | for line in sys.stdin: | |
15 | # Remove trailing newline character | |
16 | line = line.strip() | |
17 | lines.append(line) | |
18 | ||
19 | # Print to stdout | |
20 | for line in lines: | |
21 | print(line) | |
22 | ||
23 | if __name__ == "__main__": | |
24 | read_stdin() |