File: striplog

package info (click to toggle)
gpsd 2.33-4
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 2,900 kB
  • ctags: 1,861
  • sloc: ansic: 14,508; sh: 9,158; xml: 2,657; python: 1,446; makefile: 334; cpp: 120; perl: 22
file content (25 lines) | stat: -rwxr-xr-x 558 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/python
#
# striplog -- strip leading lines from logs
#
# striplog -1 strips the first line only.
# striplog with no option strips all leading lines beginning with #
#
import getopt, sys

firstline = False
(options, argumwnts) = getopt.getopt(sys.argv[1:], "1")
for (switch, val) in options:
    if (switch == '-1'):
        firstline = True

if firstline:
    sys.stdin.readline()
else:
    while True:
        line = sys.stdin.readline()
        if line[0] != '#':
            break
    sys.stdout.write(line)

sys.stdout.write(sys.stdin.read())