MESSAGE
DATE | 2011-12-15 |
FROM | Ruben Safir
|
SUBJECT | Re: [NYLXS - HANGOUT] A simple perl script
|
On Wed, Dec 14, 2011 at 09:54:19PM -0800, Elfen Magix wrote: > I was thinking of Grep as well. >
you can perldoc the perl grep function or just use a regex test
next CLOSE_CHAPTER if m"Chapter \d\d"
or something like that. I'm rusty.
> The problem is simple (maybe not): > -Its a story text file in acsii. > -It has many chapters > -The chapter index numbers 1 - 13 are fine, skips 14, and continues with 15 to 75. > -The format of the chapter line (all 75 are in 1 file) is: > "Chapter XX: Chapter Name" Where XX is any number from 0 - 9, counting all 75 chapters. > > I was thinking of grep to find the chapter lines (which I can do and does work) but changing the numbers is what I cant figure out. > > grep 'Chapter' /file name? - gets the chapter lines and posts them. But changing them? > > BTW- I can remove chapters 1 - 13 temporarily while this change happens. > > > ________________________________ > From: Kevin Mark > Subject: Re: [NYLXS - HANGOUT] A simple perl script > > On Wed, Dec 14, 2011 at 04:27:39PM -0800, Elfen Magix wrote: > > I need a simple thing that goes through a file to find "Chapter [and a number] > > ". Then it must increment that number by 1 and resave the file without altering > > nothing else. > > > > I know I've seen this, and even wrote one years ago myself, but I cant for the > > life of me remember how! > > > > Thanks. > That is sort-of a loose definition for a program specification. > if its one line in one file, you can just open it in vi and search for it and fix it. > if you need it done in 10's or 100's of places, if might be a few lines of sed, awk or grep. > > grep "Chapter" filename
|
|