Just a couple of comments...

The above suggestion is good advice, but I never liked the way that perl's -i option worked. One problem is that if you accidentally run your script twice you've just blown away your originals. Also, it's not 'transactional'. For some edits I want to be able to die and not have the original file change. For quick-and-dirty operations it can work well, but I wouldn't recommend using it for a massive editing process like you're describing. Rather, I would recommend that you:

Making the back-up copies can be done easily using the --parents switch to cp, i.e.:

mkdir backups find ... -exec cp --parents '{}' backups ';'

and this will preserve the parent path of the found files.

The other comment I have is that if you have several hundred files to edit, it might be helpful to reconsider how they are organized. It seems that your scripts are organized by <verb> <noun>, i.e. the script is the verb and the thing to act on is passed as an argument. You might look into changing this around so that the noun selects the script and the action is supplied as an argument. So instead of running:

$ start bgs

you would start up the bgs daemon by running:

$ bgs start

This will make your scripts more 'object oriented' and place similar concerns in the same script. Also, when you deploy a new version of the bgs daemon, you wouldn't have to edit all the 'start' scripts to include the new bgs code, you would just be replacing one bgs control script. Anyway, it's something to consider to see if it's applicable to your situation.


In reply to Re: I need some pearls of wisdom by pc88mxer
in thread I need some pearls of wisdom by wcj75019

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.