Difference between revisions of "BASH/C2/Introduction-to-BASH-Shell-Scripting/English-timed"
From Script | Spoken-Tutorial
Sandhya.np14 (Talk | contribs) |
|||
Line 5: | Line 5: | ||
|- | |- | ||
| 00:01 | | 00:01 | ||
− | |Dear friends, welcome to the Spoken tutorial on | + | |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: |
|- | |- | ||
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: |
|- | |- | ||
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 | + | | Let us start with an introduction. |
|- | |- | ||
Line 57: | Line 57: | ||
|- | |- | ||
| 00:56 | | 00:56 | ||
− | |* '''Bash Shell''' is a '''Command language interpreter''' | + | |* '''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''' |
|- | |- | ||
|01:11 | |01:11 | ||
− | | | + | | 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, | + | |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 | + | | 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'''- |
|- | |- | ||
|02:12 | |02:12 | ||
− | |It provides features lacking in '''Bourne Shell ''' | + | |It provides features lacking in '''Bourne Shell '''. |
|- | |- | ||
| 02:16 | | 02:16 | ||
− | | '''K Shell''' | + | | '''K Shell'''- |
|- | |- | ||
| 02:17 | | 02:17 | ||
− | | It was created by David Korn | + | | It was created by David Korn. |
|- | |- | ||
| 02:20 | | 02:20 | ||
− | |It has features of both, B Shell and C Shell | + | |It has features of both, '''B Shell''' and '''C Shell''' along with some additional features. |
|- | |- | ||
| 02:27 | | 02:27 | ||
− | | '''Bash Shell''' | + | | '''Bash Shell'''- |
|- | |- | ||
Line 157: | Line 157: | ||
|- | |- | ||
| 02:40 | | 02:40 | ||
− | | '''TC Shell''' | + | | '''TC Shell'''- |
|- | |- | ||
Line 165: | Line 165: | ||
|- | |- | ||
| 02:46 | | 02:46 | ||
− | | '''Z shell''' | + | | '''Z shell'''- |
|- | |- | ||
Line 173: | Line 173: | ||
|- | |- | ||
| 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 181: | ||
|- | |- | ||
| 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 | + | |* It tells the '''Shell''' to '''execute''' this''' text file''' instead of typing the '''commands'''. |
|- | |- | ||
Line 193: | Line 193: | ||
|- | |- | ||
| 03:20 | | 03:20 | ||
− | | We will test the '''echo''' command | + | | 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 213: | ||
|- | |- | ||
| 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 | + | | You are free to use your favorite '''text-editor'''. |
|- | |- | ||
Line 237: | Line 237: | ||
|- | |- | ||
| 04:03 | | 04:03 | ||
− | | So, type '''cd''' space '''Desktop''' | + | | So, type: '''cd''' space '''Desktop''' |
|- | |- | ||
Line 245: | Line 245: | ||
|- | |- | ||
| 04:09 | | 04:09 | ||
− | |Now type '''gedit space hello underscore world dot sh space & | + | |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 |
|- | |- | ||
Line 265: | Line 265: | ||
|- | |- | ||
| 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''' |
|- | |- | ||
Line 277: | Line 277: | ||
|- | |- | ||
|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: |
|- | |- | ||
Line 289: | Line 289: | ||
|- | |- | ||
| 05:06 | | 05:06 | ||
− | | Remember that any line after '''hash | + | | Remember that any line after '''hash''' is treated as a '''comment.''' |
|- | |- | ||
Line 297: | Line 297: | ||
|- | |- | ||
| 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''' |
|- | |- | ||
|05:20 | |05:20 | ||
− | | and type '''echo''' space within double quotes '''Hello world''' | + | | and type: '''echo''' space within double quotes '''Hello world''' |
|- | |- | ||
Line 313: | Line 313: | ||
|- | |- | ||
| 05:28 | | 05:28 | ||
− | |Type '''echo space dollar sign SHELL''' ( | + | |Type: '''echo space dollar sign SHELL''' (in Capital) |
|- | |- | ||
Line 321: | Line 321: | ||
|- | |- | ||
|05:35 | |05:35 | ||
− | | Type '''echo space backtick date backtick''' | + | | Type: '''echo space backtick date backtick''' |
|- | |- | ||
Line 333: | Line 333: | ||
|- | |- | ||
|05:50 | |05:50 | ||
− | |Let us execute | + | |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 349: | ||
|- | |- | ||
|06:12 | |06:12 | ||
− | | Now | + | | Now, type: |
|- | |- | ||
Line 365: | Line 365: | ||
|- | |- | ||
| 06:27 | | 06:27 | ||
− | | The''' shell '''type is displayed on the next line. | + | | 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. |
|- | |- | ||
|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 '''slide''' and summarize. |
|- | |- | ||
|06:46 | |06:46 | ||
− | |In this tutorial we have learnt about | + | |In this tutorial, we have learnt about: |
|- | |- | ||
Line 393: | Line 393: | ||
|- | |- | ||
|06:51 | |06:51 | ||
− | |*'''Bash Shell script''' | + | |*'''Bash Shell script'''. |
|- | |- | ||
Line 401: | Line 401: | ||
|- | |- | ||
| 06:57 | | 06:57 | ||
− | | As an assignment | + | | As an assignment- write a simple '''script''' to display the message - |
− | + | * “'''Welcome to Bash learning'''” | |
|- | |- | ||
Line 410: | Line 410: | ||
|- | |- | ||
| 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 | + | |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 | + | |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 438: | ||
|- | |- | ||
|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 | + | |The script has been contributed by FOSSEE and Spoken-Tutorial teams, IIT Bombay. |
|- | |- | ||
|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. |
|} | |} |
Revision as of 22:43, 1 July 2015
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- |
02:12 | It provides features lacking in Bourne Shell . |
02:16 | K Shell- |
02:17 | 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- |
02:41 | * 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. |
04:33 | 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 |
05:20 | and type: echo space within double quotes Hello world |
05:27 | press Enter. |
05:28 | Type: echo space dollar sign SHELL (in Capital) |
05:34 | press Enter. |
05:35 | 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 slide and summarize. |
06:46 | In this tutorial, we have learnt about: |
06:48 | * Different types of Shells |
06:50 | * Bash Shell |
06:51 | *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 -
|
07:03 | * and “***************” (asterisks) on separate lines. |
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, IIT Bombay. |
07:56 | This is Ashwini Patil from IIT Bombay, signing off. Thank you for joining. |