Last active
August 29, 2015 14:14
-
-
Save wh13371/ac4a2f5fd01061586a1f to your computer and use it in GitHub Desktop.
python - file line count
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/python | |
""" | |
Usage: ./file.line.count.py <filename> | |
Example: ./file.line.count.py error.log | |
""" | |
import sys | |
if len(sys.argv) != 2: | |
print (__doc__) | |
sys.exit(58) | |
filename = sys.argv[1] | |
num_of_lines = sum(1 for line in open(filename)) | |
print num_of_lines |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment