skiplines.py #2

  • //
  • guest/
  • lester_cheung/
  • scripts/
  • skiplines.py
  • View
  • Commits
  • Open Download .zip Download (917 B)
#!/usr/bin/env python
'''
A simple script that reads from stdin, prints to stdout while
skipping a list of line numbers specified in the arguments.

This is useful to skip a corrupted line in a journal without editing
the file.

$Id: //guest/lester_cheung/scripts/skiplines.py#2 $
$DateTime: 2013/05/15 23:06:51 $
$Author: lester_cheung $

DISCLAIMER
  User contributed content on the Perforce Public Depot is not
  supported by Perforce, although it may be supported by its
  author. This applies to all contributions even those submitted by
  Perforce employees.

  If you have any comments or need any help with the content of
  this particular folder, please contact lcheung_AT_perforce.com,
  and I will try to help.
'''

import sys
if __name__ == '__main__':
    n = 0
    targets = map(int,sys.argv[1:])
    for line in sys.stdin:
        n+=1
        if n in targets:
            continue
        print line,
# Change User Description Committed
#2 8286 Lester Cheung Added comment and made file kxtext
#1 8129 Lester Cheung A simple script that reads from stdin, prints to stdout while skipping a
list of line numbers specified in the arguments.