Difference between revisions of "BASH/C2/Introduction-to-BASH-Shell-Scripting/English-timed"

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

Latest revision as of 15:19, 23 March 2017

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 hello_world.sh 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 contact@spoken-tutorial.org
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. http://spoken-tutorial.org/NMEICT-Intro
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