Things like this:
tid=$(echo $src | sed -e "s/_.*$//")
I would change to this:
tid=${src%%_*}
Often the 'echo ... | sed ...' lines can be replaced with shell parameter expansion, which can speed up some scripts. Overall though, I don't know if it'll do much for you. Your big sed pipe could be put into one sed command, and your deletion of multiple dashes looks wrong (especially since you do it twice), do you want this?: s/--*/-/g. And as merlyn might point out, you have a few useless uses of cat. You could use either input redirection or specify the file on the first command. In keeping with your current style, this works in ksh, I don't know about bash:
<file \ sed s/this/that/g
There are cases when sed is faster than perl, and the other way around. Last time I compared, it seemed that when I used alot of character classes (e.g., [0-9], etc.) perl tended to be faster. Update: or maybe when I could replace things like [0-9] in sed with \d in perl, and needed case insensitive matches, which you can't do with the old standard sed.

In reply to Re^3: BASH vs Perl performance by runrig
in thread BASH vs Perl performance by jcoxen

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.