Skip to content

Commit 87ed47e

Browse files
committed
correct numbering lines
1 parent f3b6b52 commit 87ed47e

1 file changed

Lines changed: 2 additions & 13 deletions

File tree

  • implement-shell-tools/cat

implement-shell-tools/cat/cat.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,22 @@
1010
parser.add_argument("path", nargs="+", help="The file to search")
1111

1212
args = parser.parse_args()
13+
number = 1
1314

1415
for file_path in args.path:
1516
with open(file_path, "r") as f:
1617
content = f.readlines()
1718

1819
if args.n:
19-
number = 1
2020
for line in content:
2121
print(f"{number}\t{line.strip()}")
2222
number +=1
2323
elif args.b:
24-
number = 1
2524
for line in content:
2625
if line.strip() !="":
2726
print(f"{number}\t{line.strip()}")
2827
number +=1
2928
else:
3029
print("")
3130
else:
32-
print("".join(content))
33-
34-
35-
36-
37-
# if args.b:
38-
# number=1
39-
# for line in content:
40-
# print
41-
42-
# print(content)
31+
print("".join(content))

0 commit comments

Comments
 (0)