Skip to content

Commit 65425b4

Browse files
committed
Support multiple files in wc
1 parent afbb144 commit 65425b4

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

  • implement-shell-tools/wc

implement-shell-tools/wc/wc.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import sys
22

33
args = sys.argv[1:]
4-
path = args[0]
54

6-
with open(path, "r") as file:
7-
content = file.read()
5+
for path in args:
6+
with open(path, "r") as file:
7+
content = file.read()
88

9-
lines = content.split("\n")
10-
words = content.split(" ")
11-
chars = content
9+
lines = content.split("\n")
10+
words = content.split(" ")
11+
chars = content
1212

13-
print(len(lines), len(words), len(chars))
13+
print(len(lines), len(words), len(chars), path)

0 commit comments

Comments
 (0)