As such, optimizing them for speed is not much of an issue. Consider the case, though, where a script carries out an important task, does it well, but runs too slowly. Rewriting it in a compiled language may not be a palatable option. The simplest fix would be to rewrite the parts of the script that slow it down. Check the loops in the script.
Time consumed by repetitive operations adds up quickly.
Use the time and times tools to profile computation-intensive commands. Consider rewriting time-critical code sections in C, or even in assembler. Bash is not particularly efficient at handling files, so consider using more appropriate tools for this within the script, such as awk or Perl. Try to write your scripts in a structured, coherent form, so they can be reorganized and tightened up as necessary. Some of the optimization techniques applicable to high-level languages may work for scripts, but others, such as loop unrolling, are mostly irrelevant.