Tuesday, July 1, 2008

Shell Scipt for beginners

Scripting languages are always easy and so Shell Script is too. But before you start the shell script there are few things that I need to tell you. If you are aware of the things you can skip the first topic.

What is shell Script ?

Shell Script basics

Shell Script Conditions and Loops

Shell Script Computation and Comparison

What is Shell Script ?

Shell script of nothing but the bunch of Linux command write down in the file with condition and loops. But this is little bit different form VB Script and the Java Script in a way that it is a bit of structured script. What mean that?? that means Spaces does matter in the script.

Almost all the Linux version provides following shells. You can easily change to any of the shell but BASH is the default shell on most of the Linux version.

sh or Bourne Shell: the original shell still used on UNIX systems and in UNIX related environments. This is the basic shell, a small program with few features. While this is not the standard shell, it is still available on every Linux system for compatibility with UNIX programs.

bash or Bourne Again shell: the standard GNU shell, intuitive and flexible. On Linux, bash is the standard shell for common users. This shell is a so-called superset of the Bourne shell, a set of add-ons and plug-in. This means that the Bourne Again shell is compatible with the Bourne shell: commands that work in sh, also work in bash. However, the reverse is not always the case

csh or C shell: the syntax of this shell resembles that of the C programming language.

tcsh or Turbo C shell: a superset of the common C shell, enhancing user friendliness and speed.

ksh or the Korn shell: sometimes appreciated by people with a UNIX background

To switch to any of the above shell just write down it’s name on the terminal window and press Enter

1 comment:

Darrell said...

Some clarifications:

The Bourne shell (sh) was the original shell from UNIX. It is not open source so Linus Torvalds had to create his own shell. He called it bash for Bourne Again SHell because he was re-inventing the Bourne shell.

Linux does not have a Bourne shell. The bash shell has a mode that mimics the Bourne shell. So when you are using sh on Linux, you are really using bash with features disabled.

Additionally, the tcsh is not the Turbo C shell. Ken Greer, the author of tcsh, was inspired by the TENEX operating system. The command completion features tcsh added to csh came from TENEX.


Also, the mindset of someone doing system administration and the tasks they are dealing with are much different from a C language programmer. The C programmers on UNIX disliked the syntax of the Bourne shell. So Bill Joy (co-founder of Sun) created the csh.

Finally, Steven Korn liked some of the features of the csh but wanted to be compatible to the Bourne shell (a lot of administrator scripts existed for Bourne shell by this time). So he created the Korn shell.