python file manipulation

Posted by lakshmipathi on Stack Overflow See other posts from Stack Overflow or by lakshmipathi
Published on 2010-04-13T09:21:56Z Indexed on 2010/04/13 9:22 UTC
Read the original article Hit count: 271

Filed under:
|

I have a directory /tmp/dir with two types of file names

/tmp/dir/abc-something-server.log

/tmp/dir/xyz-something-server.log

..

..

and

/tmp/dir/something-client.log

I need append a few lines (these lines are constant) to files end with "client.log"

line 1

line 2

line 3

line 4

append these four lines to files end with "client.log"

and For files end with "server.log"

I needed to append after a keyword say "After-this". "server.log " file has multiple entries of "After-this" I need to find the first entry of "After-this" and append above said four lines keep the remaining file as it is.

Any help will be great appreciated :) Thanks in advance.

© Stack Overflow or respective owner

Related posts about python

Related posts about file