views:

157

answers:

5

What exactly is shell scripting?

And what is Bash, Korn, and Expect? I use a few commands in a Linux terminal, is that shell scripting too? Again I am confused what exactly is shell scripting?

+4  A: 

Shell scripting is the process of creating a file containing several shell commands (i.e. ls, cd, grep, etc) than can then be executed.

bash and korn are both shells - they allow you to interface with the computer through a command line, rather than running programs by clicking on icons.

The purpose of shell scripting is to automate repetitive tasks, such as setting up an environment to launch a program, or checking to see if logfiles have changed, or archiving a directory (or set of directories) or any other number of tasks.

Check this out for more info.

Wayne Werner
"The purpose of shell scripting is to automate repetitive tasks", Ohh you can do so much more then just this. That's the beauty of the unix design. http://128.10.19.20/research/technical_reports/1981/TR%2081-379.pdf
Anders
"any other number of tasks" ;) I guess I could have said "anything you want", since most (all?) shell languages are Turing complete..
Wayne Werner
+7  A: 

Your terminal runs a shell , probably bash - korn, csh and others are similar shells with different features and syntax.

While you probably use it mostly to run commands, most shells are an interpreter for command language defined by that shell. Programs in that language is called a shell script. See this howto for an overview of shell scripting in bash.

nos
to find out path to bash, I do which bash. But how would I find out where Korn is??
sai
@sai: You'd do `which ksh` since "ksh" is the name of the executable. In Bash, I prefer `type -a` over `which` because it will show you aliases and functions which may supersede an executable plus each location that an executable exists in directories in your path. Some versions of `which` don't give you that much information.
Dennis Williamson
A: 

http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=define:+shell+script

Shell scripting lets you automate tasks that you do from the command line.

karlw
+2  A: 

In addition to being an interaction environment the shell (be it the original Bourne shell (/bin/sh) or one of the many alternatives (ksh, csh, bash, zsh, tcsh, ...) with different or extended syntax) provides programming language like features (looping, conditionals, functions, variables...).

Shell scripting is more or less writing a program in you favorite shell.

The line between using the shell and scripting is fuzzy, but I'd put it near "solving a class of problems by writing some shell code that is smart in some way".

dmckee
I don't think the line is fuzzy. Although writing complex command lines is a similar activity, interactively sending commands to the shell is *not* scripting, while writing them into a file is.
William Pursell
@William: It does get fuzzy since you can use pipes, loops and conditionals on the command line. Whether a condition of being in a file is unconditionally necessary to constitute a "script" is a semantic argument.
Dennis Williamson
+1  A: 

A shell script is a script written for the shell, or command line interpreter, of an operating system. It is often considered a simple domain-specific programming language. Typical operations performed by shell scripts include file manipulation, program execution, and printing text.

Many shell script interpreters double as command line interface, such as the various Unix shells, Windows PowerShell or the MS-DOS COMMAND.COM. Others, such as AppleScript or the graphical Windows Script Host (WScript.exe), add scripting capability to computing environments without requiring a command line interface. Other examples of programming languages primarily intended for shell scripting include DCL and JCL.

Ryan Murphy
Additionally "scripting" generally implies an interpreted language. That's why sometimes you'll see references to Python or Perl "scripts" even though they aren't shells (just as AppleScript and WSH aren't).
Dennis Williamson