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 --- python/cat.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 python/cat.py (limited to 'python') 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