Re: Help with a Unix script for...

From: RHS Linux User (blue@CALICO.GATOR.NET)
Date: 10/28/97


> Hello, I have a file that has over 6500 lines of code I want to use but
> almost every line has a '+' in front of it.  The code is from a patch
> file that I couldn't get to patch so I am doing it manually.  Can anyone

or, if you're inclined for something a little meatier:

****************************
#!/usr/bin/python
# python: live it, learn it, love it.

# ok, this trims the first character from every line of file 'butt' and
# writes the new file as 'butt.out'
# you need to 'rm butt.out' every time, because this just appends the
# text..

from string import find

input = open('butt', 'r')
output = open('butt.out', 'a')

while 1:
 line = input.readline()
 if not line:
  break
 point = line[0:1]
 if find(line, '+', 0) <>-1:
  trim = line[2:-1]
  output.write(trim + '\n')
 else:
  output.write(line)

***************************************************


Blue


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/08/00 PST