Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Feb 2004 12:19:09 -0800
From:      Johnson David <DavidJohnson@Siemens.com>
To:        freebsd-newbies@freebsd.org
Cc:        Sharif Dayan <bimasena@mdp.net.id>
Subject:   Re: Greetings and salutaions..
Message-ID:  <200402251219.09459.DavidJohnson@Siemens.com>
In-Reply-To: <20040225045712.A1A9D43D2D@mx1.FreeBSD.org>
References:  <20040225045712.A1A9D43D2D@mx1.FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tuesday 24 February 2004 08:57 pm, Sharif Dayan wrote:

> I know "command-line", because I once used DOS, but what is
> "shell-scripting" ?

This will be a similar answer to others, but explained a bit 
differently...

Under DOS/Windows you have a command shell. It's called "command.com" in 
DOS. There is a "cmd.exe" shell in NT/XP, but I don't know anything 
about it. The DOS shell is very limited. There is file redirection, but 
not as powerful as in UNIX. There are pipes, but few low level 
utilities can use it. Scripting is limited to (essentially) a 
sequential series of commands in a batch file.

Under UNIX you have a wide variety of shells. There are two basic 
families of shells, "Bourne" and "C", based on the two earliest shells, 
sh (Bourne) and csh (C). The Bourne shell spawned the Korn shell (ksh) 
and GNU's Bourne Again Shell (bash). csh spawned tcsh, which lacking a 
formal name, I like to call the "Taco Shell". FreeBSD ships with sh and 
tcsh as part of the base system, while bash and ksh are available in 
ports. I would highly recommend using bash as the default shell for all 
user accounts (not root though).

Since UNIX has very flexible file redirection and pipes, you can 
construct some very poweful commands in the shell. There was no GUI (or 
even two dimensional screen based interfaces) when UNIX was in its 
infancy, so everything had to be done on the command line, and line by 
line. But except for having to memorize many commands and their 
options, this was not a hindrance, because you could (and can) do some 
amazing things on the command line.

The power is extended to shell scripts. A script is nothing more than a 
file that contains shell commands. But since UNIX shells have some 
programming constructs built in (conditionals, loops, etc), scripts are 
really programs, and not mere batch files. Bourne shells are the best 
for writing scripts, and my recommendation is to always use the plain 
vanilla "sh" for scripting.

How powerful are shell scripts? Consider that once the FreeBSD kernel 
has finished loading and initializing, virtually everything else at 
bootup is done through a shell script. All of the daily, weekly and 
monthly security checks and reports are done with shell scripts.

Shell scripts are the glue that hold UNIX together. But they're simple 
and versatile enough for even you to learn and use every day.

Cheers,

David Johnson



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200402251219.09459.DavidJohnson>