Skip to content

Instantly share code, notes, and snippets.

@wh13371
Last active August 29, 2015 14:14
Show Gist options
  • Save wh13371/ac4a2f5fd01061586a1f to your computer and use it in GitHub Desktop.
Save wh13371/ac4a2f5fd01061586a1f to your computer and use it in GitHub Desktop.
python - file line count
#! /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