Script tuning in Bash

SCRIPT WORKOUT

Article from Issue 64/2006
Author(s):

In the old days, shells were capable of little more than calling external programs and executing basic, internal commands. With all the bells and whistles in the latest versions of Bash, however, you hardly need the support of external tools.

Many scripts treat Bash as if it were capable of little more than calling external programs. This is surprising, since version 2 of the default shell has a command set that covers everything from complex string manipulation, through regular expressions, to arrays; useful functions that make expensive program calls redundant. The main advantage of internal functions is that the shell does not need to spawn a new process, which saves processing time and memory. This capability can be important, particularly if you need to launch a program like grep or cut in a loop, as the completion time and memory consumption of a script can explode if you’re not careful. This article describes some simple techiques for speeding up your Bash scripts.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Bash 4

    Despite the Bourne-again shell's biblical age and high level of maturity, developers continue to work on it. We take a look at the latest Bash release.

  • Bash vs. Vista PowerShell

    Microsoft’s new PowerShell relies on .NET framework libraries and thus has access to a treasure trove of functions and objects. How does PowerShell measure up to traditional shells like Bash?

  • Introducing Bash

    Beyond all the splash screens, screen savers, and vivid rock-star wallpaper is the simple yet powerful Bash shell.

  • SHC: Bash Script Compiler

    The Bash Shell Script Compiler converts shell scripts directly into binaries. Compiling your scripts provides protection against accidental changes, but you will have to contend with some quirks.

  • Command Line

    A few basic tricks can liven up the command line and add a dash of color to your console.

comments powered by Disqus

Direct Download

Read full article as PDF:

Script_Tuning_in_Bash.pdf (147.91 kB)

News