We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0e47055 commit f4ce299Copy full SHA for f4ce299
1 file changed
implement-shell-tools/cat/cat.py
@@ -2,8 +2,24 @@
2
3
args = sys.argv[1:]
4
5
-path = args[0]
+show_numbers = False
6
+paths = []
7
-with open(path, "r") as file:
8
- content = file.read()
9
- print(content)
+# separate flags and paths
+for arg in args:
10
+ if arg == "-n":
11
+ show_numbers = True
12
+ else:
13
+ paths.append(arg)
14
+
15
+for path in paths:
16
+ with open(path, "r") as file:
17
+ lines = file.readlines()
18
19
+ if show_numbers:
20
+ i = 1
21
+ for line in lines:
22
+ print(f"{i} {line.rstrip()}")
23
+ i += 1
24
25
+ print("".join(lines))
0 commit comments