This shell script and shell programming site aims to provide book reviews and free ebook on bash shell, korn shell, shell commands, linux shell, awk shell, unix commands, ftp shell and all other shells.

O'reilly Learning the Korn Shell

By Bill Rosenblatt
The long, tortuous history of the UNIX operating system has resulted in systems with all kinds of permutations and combinations of features. This means that whenever you walk up to an unfamiliar UNIX system, you need to find out certain things about it in order to use it properly. And even on a given system, you may have a number of choices you can make about what features you want to use.
The most important such decision - if you get to make it - is what shell to use. "Shell" is UNIX jargon for the program that allows you to communicate with the computer by entering commands and getting responses. The shell is completely separate from the UNIX operating system per se; it's just a program that runs on UNIX. With other systems such as MS-DOS, the Macintosh, and VM/CMS, the command interpreter or user interface is an integral part of the operating system.
Nowadays there are dozens of different shells floating around, ranging from the original standard, the Bourne shell, to menu-based and graphical interfaces. The most important shells have been the Bourne shell, the C shell, and now the Korn shell - the subject of this book.

Easy Shell Scripting

By Blessen Cherian
Shell scripting can be defined as a group of commands executed in sequence. Let's start by describing the steps needed to write and execute a shell script:
Step 1: Open the file using an editor (e.g., "vi" or "pico".) vi Firstshellscript.sh
Step 2: All shell scripts should begin with "#!/bin/bash" or whatever other shell you prefer. This line is called the shebang, and although it looks like a comment, it's not: it notifies the shell of the interpreter to be used for the script. The provided path must be an absolute one (you can't just use "bash", for example), and the shebang must be located on the first line of the script without any preceding space.
Step 3: Write the code that you want to develop. Our first shell script will be the usual "Hello World" routine, which we'll place in a file called 'Firstshellscript.sh'.
#!/bin/sh
echo "Hello World"
Step 4:The next step is to make the script executable by using the "chmod" command.
chmod 744 Firstshellscript.sh
or chmod +x Firstshellscript.sh
Step 5: Execute the script. This can be done by entering the name of the script on the command line, preceded by its path. If it's in the current directory, this is very simple:
bash$ ./Firstshellscript.sh
Hello World
If you want to see the execution step-by-step - which is very useful for troubleshooting - then execute it with the '-x' ('expand arguments') option:
sh -x Firstshellscript.sh
+ echo 'Hello World'
Hello World
Shell scripting can be defined as a group of commands executed in sequence.
To see the contents of a script, you can use the 'cat' command or simply open the script in any text editor:
bash$ cat Firstshellscript.sh
#!/bin/sh
echo Hello World
Click to Read More

Example Shell Scripts

Context-Switch
Solaris 10 Scripts

nfsclients
A shell script that will display whether or not a Solaris 10 NFS server has any active client NFS mounts. An active mount is assessed as being either mounted within the last 5 minutes or actively being used within the last 5 minutes. Whilst clients may have NFS mounts in place, if they have been inactive for a period of 5 minutes or more, the server drops the reference to that mount. This script should show the IP address and hostname of the client, if the client details are to be found in the server's host database files. The script does not try to resolve hostnames that are stored in a NIS or LDAP naming service database.
Solaris performance
diskstat
A shell script that uses the kstat utility to determine disk I/O for all disk partitions on a system. The script is intended to determine whether system-connected disks are mainly read or write intensive.
netbytes
A shell script that also uses the kstat utility, but this time to determine network throughput (in bytes) for each network port of the system. The script is intended to show whether the network ports are busy in addition to showing the throughput (input and output) in bytes rather than packets.
map_procs
This script uses the mdb utility to determine the address space mapping for all running processes that were captured in a crash dump. The script also tests for memory leaks and displays kernel memory cache statistics.

Sams Teach Yourself Shell Programming in 24 Hours

In recent years, the UNIX operating system has seen a huge boost in its popularity, especially with the emergence of Linux. For programmers and users of UNIX, this comes as no surprise: UNIX was designed to provide an environment that's powerful yet easy to use.
One of the main strengths of UNIX is that it comes with a large collection of standard programs. These programs perform a wide variety of tasks from listing your files to reading email. Unlike other operating systems, one of the key features of UNIX is that these programs can be combined to perform complicated tasks and solve your problems.
One of the most powerful standard programs available in UNIX is the shell. The shell is a program that provides you with a consistent and easy-to-use environment for executing programs in UNIX. If you have ever used a UNIX system, you have interacted with the shell.
The main responsibility of the shell is to read the commands you type and then ask the UNIX kernel to perform these commands. In addition to this, the shell provides sophisticated programming constructs that enable you to make decisions, repeatedly execute commands, create functions, and store values in variables.
This book concentrates on the standard UNIX shell called the Bourne shell. When Dennis Ritche and Ken Thompson were developing much of UNIX in the early 1970s, they used a very simple shell. The first real shell, written by Stephen Bourne, appeared in the mid 1970s. The original Bourne shell has changed slightly over the years; some features were added and others were removed, but its syntax and its resulting power have remained the same.
The most attractive feature of the shell is that it enables you to create scripts. Scripts are files that contain a list of commands you want to run. Because every script is contained in a file and every file has a name, scripts enable you to combine existing programs to create completely new programs that solve your problems. This book teaches you how to create, execute, modify, and debug shell scripts quickly and easily. After you get used to writing scripts, you will find yourself solving more and more problems with them.
Click to Read More

Learning the Shell

By William Shotts, Jr.
What is "the shell"?
Simply put, the shell is a program that takes your commands from the keyboard and gives them to the operating system to perform. In the old days, it was the only user interface available on a Unix computer. Nowadays, we have graphical user interfaces (GUIs) in addition to command line interfaces (CLIs) such as the shell.
On most Linux systems a program called bash (which stands for Bourne Again SHell, an enhanced version of the original Bourne shell program, sh, written by Steve Bourne) acts as the shell program. There are several additional shell programs available on a typical Linux system. These include: ksh, tcsh and zsh.
What's an xterm, gnome-terminal, konsole, etc.?
These are called "terminal emulators." They are programs that put a window up and let you interact with the shell. There are a bunch of different terminal emulators you can use. Most Linux distributions supply several, such as: xterm, rxvt, konsole, kvt, gnome-terminal, nxterm, and eterm.

THE Unix SHELL GUIDE

By Norman J. Buchanan and Douglas M. Gingrich
What is a shell?
A shell is a command interpreter. While this is certainly true it likely doesn't enlighten the reader any further. A shell is an entity that takes input from the user and deals with the computer rather than have the user deal directly with the computer. If the user had to deal directly with the computer he would not get much done as the computer only understands strings of 1's and 0's. While this is a bit of a misrepresentation of what the shell actually does (the idea of an operating system is neglected) it provides a rough idea that should cause the reader to be grateful that there is such a thing as a shell. A good way to view a shell is as follows. When a person drives a car, that person doesn't have to actually adjust every detail that goes along with making the engine run, or the electronic system controlling all of the engine timing and so on. All the user (or driver in this example) needs to know is that D means drive and that pressing accelerator pedal will make the car go faster or slower. The dashboard would also be considered part of the the shell since pertinent information relating to the user's involvement in operating the car is displayed there. In fact any part of the car that the user has control of during operation of the car would be considered part of the shell. I think the idea of what a shell is coming clear now. It is a program that allows the user to use the computer without him having to deal directly with it. It is in a sense a protective shell that prevents the user and computer from coming into contact with one another.
Basic Unix primer
While it assumed that the reader has a familiarity of Unix, a brief overview can only enhance previous knowledge. Unix comes in a variety of constantly changing flavors (SUNOS, HPUX, BSD and Solaris, just to name a few). Each of these Unix types will have small variations from all of the others. This may seem a bit discouraging at first, but in reality each version of Unix has more in common with all of the others than differences. The ls, for example, will give a listing of the current directory in any Unix environment. The changes or semantics local to any particular brand of Unix should be explained in the man pages that come with that particular system. The purpose of this book is not to explore the differences between differnt Unix flavors but rather to assume that they are all equivalent and look at how the different shells behave. Hence, the rest of the book assumes a kind of generic Unix operating system (except where explicitly stated otherwise).

Followers