/Shell scripting

Shell scripting

What is shell scripting ?!

Before we define shell scripting we must define script !

script :

is used to refer to any program written in the Bourne shell language (Bourne shell is the traditional UNIX /bin/sh) or its deriv- atives . The UNIX shell is not just the primary user interface of a traditional UNIX system; it is also a ­ ull-­ eatured programming language

back to shell scripting : simply shell scripting is set of shell commands to execute it in the same

Shell scripts are not a complete replacement for programs in other languages. One issue is that the shell is almost always slower than a compiled language,

The Bourne Shell Family :

1- Borne shell (old sh): named by Started shells
2- POSIX shell (sh):

3- Almquist shell (ash)

4- Bourne-again shell (bash)

5- Debian Almquist shell (dash)

6- Korn shell (ksh)

7- Public-domain Korn shell (pdksh)

8- Z shell (zsh)

There is a question ! ‘ difference between bash and shell scripting ?! ‘

Bash is just one of a number of available shells or Linux, Unix and other Unix-like operating systems. It tends to be the most popular shell for Linux users, but other shells are also popular, e.g. csh, tcsh, ksh, zsh -Bourne shell- . To claim proficiency at shell scripting you should probably know more than one shell, although bash is a good start

Before scripting we must learn how to invoke my script :

  • By

    1- . (dor) + script name or

    2- source + script name

    NOTE : we must make the fist line in script such that #!/bin/bash named by ‘marker’ to make sure that my script runs in the shell

    Let ‘s nshell 😀 !

    First script : hello world

    – make file and open it


    echo ‘hello world’

    echo ‘hello


    echo ‘hello , world ‘

    • open terminal and make this

      $cd + file path

      $ . file name or $source + filename


    Second scr ipt : variables




    echo hello, $name




    echo please enter your name : ;

    read name

    echo hello , $name


    thank you , Ramdan Karim