Re: How to use sed to remove a line from a cron file and also remove all commented lines directly above it
Cameron Simpson <[email protected]>
| Newsgroups | gmane.editors.sed.user |
|---|---|
| Message-ID | <[email protected]> |
On 10Jul2012 13:57, [email protected] <[email protected]> wrote: | From: "Jim Schneider" <[email protected]> | > [...] I realize I'm cheating here but | > crontab -l | grep -p -v 'Purge tables' > new.crontab | > | > will do the trick. The '-p' flag treats blocks of text separated by | > blank lines as a single unit. The '-v' flag excludes that block of text. | > After verifying new.crontab, move it into place. | > | > I realize I'm suggesting unix commands in place of sed and don't intend to offend this group. | | Thanks, I learned something from that answer. But again, PLEASE, reply inline and trim redundant text. It makes things MUCH easier for the readers. | However, when I sent the original email, there were no blank lines in the text. | Those were inserted by something between my Comcast account and the users group. | I think cron doesn't allow blank lines. It does. Please read "man 5 crontab". An excerpt: Blank lines and leading spaces and tabs are ignored. Lines whose first non-space character is a pound-sign (#) are comments, and are ignored. | Also, I am looking to remove the block of commented lines, if any, that are directly | above the specified pattern. In the example I gave it begins with "# Purge" but in general | it could be any commented line (or no line at all). I would also be uncomfortable about grep's -p option here: it only takes an accidental (manual) removal of the blank lines between clauses to bundle two command lines in the one paragraph, and then badness ensues. Cheers, -- Cameron Simpson <[email protected]> >>>How do you blip the throttle and wave? Do you blip it real high, then wave >>>before the revs drop back? >>Blip = right hand; Wave = left hand. Do both simultaneously. QED. >Doesnt this make the bike lurch forward thru the intersection? Not if the disk lock is in place... - Dean Woodward <[email protected]>