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 b5089a2 commit 0318f77Copy full SHA for 0318f77
implement-shell-tools/cat/cat.py
@@ -0,0 +1,29 @@
1
+import argparse
2
+
3
+parser = argparse.ArgumentParser()
4
+parser.add_argument("files", nargs="+")
5
+parser.add_argument("-n", action="store_true")
6
+parser.add_argument("-b", action="store_true")
7
8
+args = parser.parse_args()
9
10
+line_number = 1
11
12
+for file in args.files:
13
+ try:
14
+ f = open(file, "r")
15
16
+ for line in f:
17
+ if args.b and line.strip() != "":
18
+ print(f" {line_number}", line, end="")
19
+ line_number += 1
20
+ elif args.n and not args.b:
21
22
23
+ else:
24
+ print(line, end="")
25
26
+ f.close()
27
28
+ except:
29
+ print("cat:", file, "not found")
0 commit comments