From 3fed2f0b637ca18343fb0082e44532d470c1b61f Mon Sep 17 00:00:00 2001 From: Christian Cleberg Date: Tue, 20 May 2025 14:37:37 -0500 Subject: feat: add 'cat' script in Python --- .gitignore | 1 + python/cat.py | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 .gitignore create mode 100644 python/cat.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7c17ac2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +python/venv \ No newline at end of file diff --git a/python/cat.py b/python/cat.py new file mode 100644 index 0000000..d93ba65 --- /dev/null +++ b/python/cat.py @@ -0,0 +1,13 @@ +import argparse + +# Create an argument parser to obtain file name +parser = argparse.ArgumentParser(description='cat') +parser.add_argument('-f', '--file', help='File name') +args = parser.parse_args() + +# Open the file using the `file` argument +path = args.file +with open(path, 'r') as file: + # Read and print the file contents + contents = file.read() + print(contents) -- cgit v1.2.3-70-g09d2