cmc/learn

My personal learning area.

clone: git clone https://gitbay.org/cmc/learn.git

3fed2f0b637ca18343fb0082e44532d470c1b61f

verified · cmc

author: Christian Cleberg <hello@cleberg.net> · 2025-05-20T19:37:37Z

feat: add 'cat' script in Python
 .gitignore    |  1 +
 python/cat.py | 13 +++++++++++++
 2 files changed, 14 insertions(+)

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)