Skip to content

Commit afbb144

Browse files
committed
Add basic wc for single file
1 parent 5fe87a0 commit afbb144

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

  • implement-shell-tools/wc

implement-shell-tools/wc/wc.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import sys
2+
3+
args = sys.argv[1:]
4+
path = args[0]
5+
6+
with open(path, "r") as file:
7+
content = file.read()
8+
9+
lines = content.split("\n")
10+
words = content.split(" ")
11+
chars = content
12+
13+
print(len(lines), len(words), len(chars))

0 commit comments

Comments
 (0)