Jump to content

Shell Programming


Recommended Posts

Well to begin with Shell Script is its own language. Beyond that, I would probably list the languages in the following order:

 

1. Perl

2. Python

3. Ruby

4. C

 

This does not include languages like C++ or Java as they tend to be a little heavy when it comes to scripting.

Link to comment
Share on other sites

I wouldn't call bash scripting universal - especially as many people like to use other shells. That said bash is the default shell in most distros....

 

Which scripting language is most useful obviously depends on what you want to do, IME you can't go wrong with bash and perl.

Link to comment
Share on other sites

Thanks alot . I know 3/5 of the listed langueages. I was just wandering if there was like a universal shell language.

There is, it is called Shell Script, of which bash is simply a form. There is also C shell, Korn Shell, and a few others. All of which are available to Linux (although, not always installed by default). However, all of these shells use a form of Shell Script. Bash is simply the most popular when it comes to Linux. (However, it is not necessarily the most powerfull or the easiest to use.)

 

However, with all that said, Shell Script is not always the easiest, or most efficient, language to use. For an example of Shell Script, take a look at your .profile or .bashrc file. This is simply a Shell Script.

 

Shell Script is composed of a combination of the commands that you use at the command line like mv, cp, grep, cat, find, and all the rest working together with various programming constructs like if statements and loops. Generally, you use things like if statements and loops to control the input and the output of various Linux commands.

Link to comment
Share on other sites

I can't think of one where bash isn't the default shell. I'm curious, is there some linux distro out there using something other than bash for the default shell?

 

It's not a Linux distro but Tru64 UNIX (v5.1) seems to install ksh as the default shell, and thats proper ksh not pdksh that you get with most distros.

Link to comment
Share on other sites

Here at work we also use ksh a lot, HP-UX. The difference with the PDksh is actually very annoying in the move toward linux - and yes, that's where we're going, for compute servers at least.

 

 

Anyway, somewhere along the line in Linux development, the Bourne Again SHell was chosen to be the main shell. I think it may not even be possible to run any distro without it, unless you rewrite a lot to exclude it, and it is afaik always present on a distribution.

Link to comment
Share on other sites

  However, it is not necessarily the most powerfull or the easiest to use

IMHO you are half right, it is NOT the most powerfull, since that price belongs to zsh; but it IS the easier to use because (or at least since) it is the DEFAULT one, at least in LINUX. Old UNIXes, which some are still used but quickly wiped out by linux, used and/or use csh or 'sh' variations such as ksh, tcsh..., but now-a-days GNU-bash is the 'de facto' standard shell and the most used in shell scripting (or dirty programming).

 

One good source of info and resources is the usenet group comp.unix.shell the habitat of shell gurus

 

more shell examples doing cat /etc/shells

~# cat /etc/shells 
# /etc/shells: valid login shells
/bin/ash
/bin/bash
/bin/csh
/bin/sh
/usr/bin/es
/usr/bin/ksh
/bin/ksh
/usr/bin/rc
/usr/bin/tcsh
/bin/tcsh
/bin/sash
/usr/bin/esh
/usr/bin/screen
/bin/dash
/bin/zsh
/usr/bin/zsh

 

Ofcourse you can do shell scripting with which ever language you like as long as it provides you easy, quick and dirty means of writing code (even w/o editors) and as long as it has a good set of system tools or routines. IMHO bash is the best at this since it has a powerful and flexible set of builtin commands and uses the system (really-) power tools in a clean and transparent way, after all it is a system shell :) Other excellent programing languages for shell scripting are Perl (which I don't like, but when comes into dirty-shell scripting is the king) and python (my second preferred language after bash)

 

All is IMHO, and I'm not going to discuss if bash is a full language or not or if it's suitable of comparations with 'real' ones; but when talking about shell scripting it's certainly is the best language.

Edited by aru
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...