1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
#!/usr/bin/env python
# -*- coding: utf-8-with-signature-unix; fill-column: 77 -*-
# -*- indent-tabs-mode: nil -*-
# output all but the first N lines of a file
# Allen Short and Jp Calderone wrote this coool version:
import itertools, sys
def main():
K = int(sys.argv[1])
if len(sys.argv) > 2:
fname = sys.argv[2]
inf = open(fname, 'r')
else:
inf = sys.stdin
sys.stdout.writelines(itertools.islice(inf, K, None))
if __name__ == '__main__':
main()
# thus replacing my dumb version:
# # from the Python Standard Library
# import sys
#
# i = K
# for l in sys.stdin.readlines():
# if i:
# i -= 1
# else:
# print l,
|