File: subst.py

package info (click to toggle)
apoo 2.2-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, squeeze, wheezy
  • size: 560 kB
  • ctags: 425
  • sloc: python: 3,092; perl: 100; makefile: 56; sh: 4
file content (12 lines) | stat: -rwxr-xr-x 309 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
#!/usr/bin/python
from sys import __stdin__, __stdout__, argv
import sys, string

if len(argv) != 3:
    print "Usage: subst.py str1 str2"
    print "  substitutes str1 with str2 in te stdin."
    sys.exit(1)

for line in __stdin__.readlines():
    line = string.replace(line,argv[1],argv[2])
    print line,