From Script | Spoken-Tutorial
Jump to: navigation, search
Time Narration
00:01 Dear friends, welcome to the Spoken tutorial on Introduction to BASH shell scripting.
00:08 In this tutorial, we will learn:
00:10 About different types of Shells
00:13 To write a Bash Shell script and
00:16 To execute it.
00:18 To follow this tutorial, you should be familiar with Linux Operating System.
00:25 If not, then for relevant Linux tutorials, please visit our website which is as shown.
00:32 For this tutorial, I am using:
00:35 Ubuntu Linux 12.04 OS and
00:39 GNU Bash version 4.1.10.
00:43 Please note, GNU Bash version 4 or above is recommended for practice.
00:50 Let us start with an introduction.
00:53 We will see what a Bash Shell is.
00:56 Bash Shell is a command language interpreter that executes commands.
01:02 These commands are read from the standard input device.
01:07 The input device can be-
01:09 your keyboard
01:11 or a simple text file.
01:14 Let me show you what is a Bash Shell.
01:16 Open the terminal window by pressing Ctrl+Alt+T keys simultaneously on your keyboard .
01:24 This will open the Gnome terminal.
01:27 To check which type of shell we are using, type: echo space dollar sign SHELL (in capital).
01:38 Press Enter.
01:40 You will see the output printed on the next line as: slash bin slash bash.
01:47 This indicates that we are using the Bash Shell.
01:51 Now, let us know different types of Shells available.
01:56 Let us switch back to our slides. Bourne Shell-
02:00 This was original UNIX shell written by Stephen Bourne.
02:06 It lacked interactivity provided by most modern shells today.
02:11 C Shell-It provides features lacking in Bourne Shell .
02:16 K Shell- It was created by David Korn.
02:20 It has features of both, B Shell and C Shell along with some additional features.
02:27 Bash Shell-
02:30 The Bash Shell was developed by GNU Project.
02:32 It is based on B Shell language.
02:35 It has features of C and K Shells.
02:40 TC Shell-It is the default Shell of FreeBSD and its descendants.
02:46 Z shell-
02:49 It is a Shell designed for interactive use.
02:52 It has many useful features of ksh, bash and tcsh.
02:58 Now let us see what a Bash Shell script is.
03:02 The Bash Shell script contains a series of Bash commands in plain text file.
03:08 It tells the Shell to execute this text file instead of typing the commands.
03:15 Let us see how to write a simple Bash script.
03:20 We will test the echo command which will print Hello World on the terminal.
03:25 Go back to the terminal.
03:29 Now, type: echo space within double quotes Hello world
03:35 and press Enter.
03:37 This prints Hello World on the terminal.
03:40 The command worked as expected.
03:43 Now, what if we want to use this command in a file?
03:47 Just put this command in a file and execute that file.
03:52 I will use gedit text-editor for this purpose.
03:57 You are free to use your favorite text-editor.
04:00 I want to create my file on the Desktop.
04:03 So, type: cd space Desktop
04:07 Press Enter.
04:09 Now, type: gedit space hello underscore world dot sh space &(ampersand sign).
04:20 gedit is the text editor. 'Hello underscore world dot sh' is the file name and
04:27 we use the & (ampersand) to free up the prompt.
04:32 Now press Enter.We have opened a new file named using gedit.
04:40 Now, type: hash exclamation mark front slash bin front slash bash
04:47 This is the first line of every bash script.
04:51 It is called as shebang or bang line.
04:55 Press Enter.
04:57 Now, let's add a comment to the file by typing:
05:00 hash space My first Bash script
05:06 Remember that any line after hash is treated as a comment.
05:11 And comments are ignored by the Bash interpreter.
05:15 Now we can add the command which we used earlier.
05:19 Press Enter and type: echo space within double quotes Hello world.
05:27 Press Enter.Type: echo space dollar-sign SHELL (in Capital)
05:34 press Enter.Type: echo space backtick date backtick
05:41 backtick symbol is present on the key which has tilde character.
05:47 Now, click on Save to save the file.
05:50 Let us execute. Come back to our terminal.
05:55 First, we have to make the file executable.
05:58 For this, type: chmod space plus x space hello underscore world dot sh
06:09 and press Enter.
06:12 Now, type:
06:14 dot slash hello underscore world dot sh
06:19 Press Enter.
06:22 You can see Hello World is displayed on the terminal.
06:27 The shell type is displayed on the next line. i.e slash bin slash bash
06:32 and day, month, time, time zone and year are displayed.
06:38 The output may vary depending on the system.
06:43 Let us go back to our slides and summarize.
06:46 In this tutorial, we have learnt about:
06:48 Different types of Shells
06:50 Bash Shell .Bash Shell script.
06:52 To write a simple Shell script and to execute the script.
06:57 As an assignment- write a simple script to display the message -“Welcome to Bash learning
07:03 and “***************” (asterisks) on separate line.
07:06 Watch the video available at the link shown below.
07:10 It summarizes the Spoken-Tutorial project.
07:13 If you do not have good bandwidth, you can download and watch it.
07:17 The Spoken-Tutorial Project team:
07:20 Conducts workshops using spoken tutorials.
07:22 Gives certificates to those who pass an online test.
07:26 For more details, please write to
07:34 Spoken Tutorial Project is a part of the "Talk to a Teacher" project.
07:39 It is supported by the National Mission on Education through ICT, MHRD, Government of India.
07:45 More information on this mission is available at the link shown below.
07:51 The script has been contributed by FOSSEE and Spoken-Tutorial teams.
07:56 This is Ashwini Patil from IIT Bombay, signing off. Thank you for joining.

Contributors and Content Editors

PoojaMoolya, Pratik kamble, Sandhya.np14