On Thu, February 21, 2008 2:42 pm, Ralph Shumaker wrote: > My sig file grows larger. And every once in a while, I want to be > selective about which sigs are selected by my random sig selector (a > plugin for thunderbird). >
To date I've written perhaps three sig daemons and lost them all in machine upgrades. I'm about to write yet another (I'll be taking my email back in-house after too long a time on a browser interface). > I thought about making a script that moves the sig file out of the way, > and greps certain lines from the main sig file (now a different name), > and dumps them into a sig file of the original name. But my problem is > that I need grep to cough up everything between the two "%" delimiters, > not just the matching line. And further, if more than one sig matches, > I don't want two successive delimiter lines. And finally, I don't want > a delimiter line at the beginning or end of the resulting file. > This is a nice wrinkle. Hmm ... need to be able to signal it (one of the interrupt keystrokes in /etc/inittab?) and then pop down a search string. Must think ... > I don't have much experience with such things outside of DOS batch > files, and even that was long ago. But I'm thinking I may need to use > grep -n STRING to identify the line numbers of the matches, and grep -n > ^%$ to identify the delimiter lines. But then it would be a matter of > telling sed to grab the appropriate line numbers. But how do I get the > script to calculate which line numbers? > > Is there a decent online resource or three that has information fit for > a beginner but is capable of getting me where I want to go? > > Here's my rudimentary understanding of what I need in my script. But > first, from the command line: > > $ filterSigs Lan > > <script filterSigs> > #!/bin/bash > mv sigFile sigFileOriginal > grep -n $1 <sigFileOriginal > matchingLinesOnly > # This yields 10 quotes of Lan, and one quote mentioning Lan's name > grep -n ^%$ <sigFileOriginal > delimiterLinesOnly > # Now to start a new selective subset sig file > echo Ralph\<br\>> sigFile > echo \<br\>>> sigFile > echo -------------------->> sigFile > echo $>> sigFile > # I need a way for the script file to know that I > # need lines 11 thru 13, > # then 23-25, 32-34, 104-106, 166-168, 169-171, > # then 216-218, 243-245, 270-272, & 294-303 > # except that since 303 is the final delimiter, > # just drop that one. > # Note that the quotes grep tagged were all > # 3 lines each (including delimiter line) except > # the final one, which was 10 lines (only 9 if you > # drop the final delimiter line). > </script filterSigs> > > <file matchingLinesOnly> > 12:--Lan Barnes<br> > 24:--Lan Barnes<br> > 33:--Lan Barnes<br> > 105:--Lan Barnes<br> > 167:--Lan Barnes<br> > 170:--Lan Barnes<br> > 216:Suppose a supernatural being, say Zeus, threw lightning bolts at > Lan's house. Since one of his fundamental assumptions is that there's > no supernatural, his explanation will necessarily not acknowledge the > possibility of a supernatural being throwing lightning bolts. He will > find an explanation that /fits/.<br> > 244:--Lan Barnes<br> > 271:--Lan Barnes<br> > 296:--Lan Barnes<br> > 302:--Lan Barnes<br> > </file matchingLinesOnly> > > <file delimiterLinesOnly> > 7:% > 10:% > 13:% > 16:% > 19:% > 22:% > 25:% > 28:% > 31:% > 34:% > 40:% > 43:% > 45:% > 48:% > 51:% > 54:% > 57:% > 60:% > 63:% > 66:% > 69:% > 72:% > 75:% > 79:% > 82:% > 85:% > 89:% > 94:% > 100:% > 103:% > 106:% > 109:% > 113:% > 116:% > 119:% > 122:% > 125:% > 128:% > 131:% > 134:% > 138:% > 144:% > 147:% > 150:% > 153:% > 159:% > 162:% > 165:% > 168:% > 171:% > 174:% > 177:% > 180:% > 183:% > 188:% > 194:% > 197:% > 201:% > 206:% > 209:% > 212:% > 215:% > 218:% > 221:% > 224:% > 230:% > 233:% > 236:% > 239:% > 242:% > 245:% > 251:% > 254:% > 257:% > 263:% > 269:% > 272:% > 275:% > 278:% > 284:% > 287:% > 290:% > 293:% > 303:% > 306:% > 309:% > 312:% > </file delimiterLinesOnly> > > > > -- > Ralph > Seems to me that a apropos line with sig tags is a better idea. I like my dilimitor to tell where and when I got the sig, as in: # NYT Op Ed, Krugman, 2/21/08 Maybe now I should have a tag line just under it: # NYT Op Ed, Krugman, 2/21/08 % krugman oil lemurs old milwaukee That way the grep only has to find one line to display the sig. OK, Ralph, you got me thinking. But I can't promise to work on anything right now. TOO MANY PROJECTS <AAAIIIeeeeee> -- Lan Barnes SCM Analyst Linux Guy Tcl/Tk Enthusiast Biodiesel Brewer -- [email protected] http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg
