Files

15 lines
386 B
Python

#!/usr/bin/env python3
"""Line counter utility - counts lines in any text file."""
import sys
def count_lines(filepath):
with open(filepath, 'r') as f:
return sum(1 for _ in f)
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: count_lines.py <filepath>")
sys.exit(1)
count = count_lines(sys.argv[1])
print(f"Line count: {count}")