Difference between revisions of "BOSS-Linux/C3/More-on-grep-command/English-timed"
From Script | Spoken-Tutorial
PoojaMoolya (Talk | contribs) |
|||
(3 intermediate revisions by 2 users not shown) | |||
Line 5: | Line 5: | ||
|- | |- | ||
| 00:01 | | 00:01 | ||
− | | Welcome to the spoken tutorial | + | | Welcome to the '''spoken tutorial''' on '''more on grep'''. |
|- | |- | ||
| 00:05 | | 00:05 | ||
− | | In this tutorial we will learn | + | | In this tutorial, we will learn |
|- | |- | ||
| 00:07 | | 00:07 | ||
− | |some more on '''grep''' | + | |some more on '''grep''' '''command'''s |
|- | |- | ||
| 00:10 | | 00:10 | ||
− | | | + | |through some examples. |
|- | |- | ||
| 00:13 | | 00:13 | ||
− | | To record this tutorial, I am using | + | | To record this tutorial, I am using: |
|- | |- | ||
| 00:16 | | 00:16 | ||
− | |'''Linux | + | |'''Linux Operating System''' and |
|- | |- | ||
Line 37: | Line 37: | ||
|- | |- | ||
| 00:29 | | 00:29 | ||
− | | As prerequisites | + | | As prerequisites- |
|- | |- | ||
| 00:31 | | 00:31 | ||
− | | | + | | you should know basics of '''Linux terminal'''. |
|- | |- | ||
Line 49: | Line 49: | ||
|- | |- | ||
| 00:37 | | 00:37 | ||
− | |For relevant tutorials please visit our website which is as shown: http://spoken-tutorial.org | + | |For relevant tutorials, please visit our website which is as shown: http://spoken-tutorial.org |
|- | |- | ||
Line 61: | Line 61: | ||
|- | |- | ||
| 00:52 | | 00:52 | ||
− | |I will use the same file '''grepdemo.txt''' | + | |I will use the same file '''grepdemo.txt'''. |
|- | |- | ||
| 00:57 | | 00:57 | ||
− | |Say we want to find information for those who are either in '''civil''' or '''electronics'''. | + | |Say, we want to find information for those who are either in '''civil''' or '''electronics'''. |
|- | |- | ||
Line 85: | Line 85: | ||
|- | |- | ||
| 01:27 | | 01:27 | ||
− | | Say you need to look into people whose title is '''choudhury'''. | + | | Say, you need to look into people whose title is '''choudhury'''. |
|- | |- | ||
| 01:32 | | 01:32 | ||
− | |The problem is different | + | |The problem is, different people spell their titles in different way. |
|- | |- | ||
| 01:38 | | 01:38 | ||
− | |So what is the solution? | + | |So, what is the solution? |
|- | |- | ||
| 01:41 | | 01:41 | ||
− | |In such cases we can use '''hyphen e''' option with '''hyphen i.''' | + | |In such cases, we can use '''hyphen e''' option with '''hyphen i.''' |
|- | |- | ||
| 01:47 | | 01:47 | ||
− | |Type: '''grep''' space '''hyphen ie''' space | + | |Type: '''grep''' space '''hyphen ie''' space within double quotes '''chaudhury''' ('c' 'h' 'a' 'u' 'd' 'h' 'u' 'r' 'y') after the quotes space '''hyphen ie''' space within double quotes '''chowdhari''' ('c' 'h' 'o' 'w' 'd' 'h' 'a' 'r' 'i') after the quotes space '''grepdemo.txt'''. |
|- | |- | ||
Line 113: | Line 113: | ||
|- | |- | ||
| 02:16 | | 02:16 | ||
− | |But there can be many other ways in which we can write the names. | + | |But, there can be many other ways in which we can write the names. |
|- | |- | ||
| 02:22 | | 02:22 | ||
− | |How many '''hyphen e''' options can we give | + | |How many '''hyphen e''' options can we give? |
|- | |- | ||
| 02:26 | | 02:26 | ||
− | |Obviously there needs to be a better way and that way is through Regular expressions. | + | |Obviously, there needs to be a better way and that way is through '''Regular expressions'''. |
|- | |- | ||
| 02:33 | | 02:33 | ||
− | | A regular expression provides a concise and flexible means for matching | + | | A 'regular expression' provides a concise and flexible means for matching '''string'''s of text |
|- | |- | ||
| 02:41 | | 02:41 | ||
− | | | + | |such as particular characters, words or patterns of characters. |
|- | |- | ||
| 02:47 | | 02:47 | ||
− | | There are a number of regular expression characters. | + | | There are a number of '''regular expression''' characters. |
|- | |- | ||
Line 141: | Line 141: | ||
|- | |- | ||
| 02:54 | | 02:54 | ||
− | | The character class | + | | The character class- |
|- | |- | ||
| 02:56 | | 02:56 | ||
− | |It allows us to specify a group of characters within a pair of square brackets . | + | |It allows us to specify a group of characters within a pair of square brackets. |
|- | |- | ||
Line 157: | Line 157: | ||
|- | |- | ||
| 03:17 | | 03:17 | ||
− | | To match '''chaudhury''' we may type at the prompt | + | | To match '''chaudhury''', we may type at the prompt: |
|- | |- | ||
| 03:22 | | 03:22 | ||
− | |'''grep''' space '''hyphen i''' space within double quotes '''ch opening square bracket ao closing square bracket opening square bracket uw closing square bracket dh opening square bracket ua closing square bracket r opening square bracket yi closing square bracket after the double quotes ''' space '''grepdemo.txt''' | + | |'''grep''' space '''hyphen i''' space within double quotes '''ch opening square-bracket ao closing square-bracket opening square-bracket uw closing square-bracket dh opening square-bracket ua closing square-bracket r opening square- bracket yi closing square-bracket after the double quotes''' space '''grepdemo.txt''' |
|- | |- | ||
Line 181: | Line 181: | ||
|- | |- | ||
| 04:07 | | 04:07 | ||
− | |First letter dash last letter of the range | + | |First letter dash last letter of the range. |
|- | |- | ||
| 04:13 | | 04:13 | ||
− | |Suppose we like to match any digit we simply write [0-9]. | + | |Suppose we like to match any digit, we simply write [0-9]. |
|- | |- | ||
Line 193: | Line 193: | ||
|- | |- | ||
| 04:24 | | 04:24 | ||
− | | The | + | | The asterisk: The asterisk refers to 0 or more occurrences of the immediately preceding character. |
|- | |- | ||
| 04:33 | | 04:33 | ||
− | |For example '''ab asterisk''' can match '''a,ab,abb,abbb''' etc. | + | |For example, '''ab asterisk''' can match '''a,ab,abb,abbb''' etc. |
|- | |- | ||
| 04:43 | | 04:43 | ||
− | | So to match the students name whose name is '''Mira''' | + | | So, to match the students name whose name is '''Mira''' |
|- | |- | ||
Line 209: | Line 209: | ||
|- | |- | ||
| 04:50 | | 04:50 | ||
− | |'''grep''' space '''hyphen i''' space within double quotes '''m opening square bracket '''ei''' closing square bracket asterisk '''r a a | + | |'''grep''' space '''hyphen i''' space within double quotes '''m opening square-bracket '''ei''' closing square bracket asterisk '''r a a''' asterisk after the quotes space '''grepdemo.txt''' |
|- | |- | ||
Line 221: | Line 221: | ||
|- | |- | ||
| 05:16 | | 05:16 | ||
− | | The '''dot''' regular expression matches any one character. | + | | The '''dot''' regular-expression matches any one character. |
|- | |- | ||
| 05:21 | | 05:21 | ||
− | | Say we want to search any words that are 4 letters long and starts with '''M.''' | + | | Say, we want to search any words that are 4 letters long and starts with '''M.''' |
|- | |- | ||
| 05:27 | | 05:27 | ||
− | |We would simply type | + | |We would simply type: |
|- | |- | ||
Line 245: | Line 245: | ||
|- | |- | ||
| 05:47 | | 05:47 | ||
− | |Here the space within the quotes is important as it would match 5 or more letter words. | + | |Here, the space within the quotes is important as it would match 5 or more letter words. |
|- | |- | ||
Line 257: | Line 257: | ||
|- | |- | ||
| 06:04 | | 06:04 | ||
− | |For that we have the '''caret | + | |For that, we have the '''caret''' sign. |
|- | |- | ||
| 06:07 | | 06:07 | ||
− | | Now if we want get those entries whose roll numbers start with '''A.''' | + | | Now, if we want to get those entries whose roll-numbers start with '''A.''' |
|- | |- | ||
Line 269: | Line 269: | ||
|- | |- | ||
| 06:18 | | 06:18 | ||
− | |We type at the prompt: '''grep ''' within double quotes '''caret sign A''' after the quotes '''grepdemo.txt''' | + | |We type at the prompt: '''grep ''' space within double quotes '''caret-sign A''' after the quotes '''grepdemo.txt''' |
|- | |- | ||
Line 281: | Line 281: | ||
|- | |- | ||
| 06:34 | | 06:34 | ||
− | | Similarly to match a pattern at the end of the file, we have the '''dollar | + | | Similarly, to match a pattern at the end of the file, we have the '''dollar''' sign. |
|- | |- | ||
| 06:40 | | 06:40 | ||
− | |To find stipends between '''7000 '''to '''8999''' we have to write: | + | |To find stipends between '''7000 '''to '''8999''', we have to write: |
|- | |- | ||
| 06:49 | | 06:49 | ||
− | |'''grep''' space within double quotes | + | |'''grep''' space within double quotes opening square bracket 78 closing square bracket '''...''' '''dollar''' sign after the quotes space '''grepdemo.txt''' |
|- | |- | ||
| 07:05 | | 07:05 | ||
− | |Press '''Enter ''' | + | |Press '''Enter '''. |
|- | |- | ||
Line 305: | Line 305: | ||
|- | |- | ||
| 07:13 | | 07:13 | ||
− | |Let us summarize. | + | | Let us summarize. |
|- | |- | ||
| 07:15 | | 07:15 | ||
− | | | + | | In this tutorial, we learnt: |
|- | |- | ||
| 07:17 | | 07:17 | ||
− | |To match more than one pattern | + | | To match more than one pattern |
|- | |- | ||
| 07:20 | | 07:20 | ||
− | |To check a word that has different spelling | + | | To check a word that has different spelling |
|- | |- | ||
| 07:23 | | 07:23 | ||
− | |Character class | + | | Character class The use of '''asterisk''' |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
| 07:27 | | 07:27 | ||
− | |To match any one character using '''dot''' | + | | To match any one character using '''dot''' |
|- | |- | ||
| 07:31 | | 07:31 | ||
− | |To match a pattern at the beginning of the file | + | | To match a pattern at the beginning of the file |
|- | |- | ||
| 07:35 | | 07:35 | ||
− | |To match a pattern at the end of the file | + | | To match a pattern at the end of the file. |
|- | |- | ||
| 07:39 | | 07:39 | ||
− | | As an assignment, | + | | As an assignment, list those entries that are 5 letters long and starts with 'Y'. |
|- | |- | ||
| 07:46 | | 07:46 | ||
− | | Watch the video available at the link shown below | + | | Watch the video available at the link shown below. |
|- | |- | ||
| 07:50 | | 07:50 | ||
− | |It | + | |It summarizes the Spoken Tutorial project |
|- | |- | ||
| 07:53 | | 07:53 | ||
− | |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:59 | | 07:59 | ||
− | | The Spoken Tutorial | + | | The '''Spoken Tutorial''' project team: conducts workshops using spoken tutorials. |
|- | |- | ||
| 08:04 | | 08:04 | ||
− | |Gives certificates to those who pass an online test | + | |Gives certificates to those who pass an online test. |
|- | |- | ||
Line 369: | Line 365: | ||
|- | |- | ||
| 08:14 | | 08:14 | ||
− | | 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. |
|- | |- | ||
| 08:19 | | 08:19 | ||
− | |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. |
|- | |- | ||
| 08:26 | | 08:26 | ||
− | |More information on this | + | |More information on this mission is available at the link shown below : http://spoken-tutorial.org\NMEICT-Intro |
|- | |- | ||
Line 385: | Line 381: | ||
|- | |- | ||
| 08:36 | | 08:36 | ||
− | |This is Ashwini Patil from IIT Bombay | + | |This is Ashwini Patil from IIT Bombay, signing off. Thank you for joining. |
|} | |} |
Latest revision as of 16:27, 7 March 2017
Time | Narration |
00:01 | Welcome to the spoken tutorial on more on grep. |
00:05 | In this tutorial, we will learn |
00:07 | some more on grep commands |
00:10 | through some examples. |
00:13 | To record this tutorial, I am using: |
00:16 | Linux Operating System and |
00:20 | GNU BASH version 4.2.24 |
00:23 | Please note, GNU bash version 4 or above is recommended to practice this tutorial. |
00:29 | As prerequisites- |
00:31 | you should know basics of Linux terminal. |
00:35 | You should be aware of grep. |
00:37 | For relevant tutorials, please visit our website which is as shown: http://spoken-tutorial.org |
00:43 | We can match more than one patterns as well. |
00:47 | Then we have to use the hyphen e option. |
00:52 | I will use the same file grepdemo.txt. |
00:57 | Say, we want to find information for those who are either in civil or electronics. |
01:04 | We need to type on the terminal: |
01:07 | grep space hyphen e space within double quotes electronics after the quotes space hyphen e space within double quotes civil after the quotes space grepdemo.txt |
01:22 | Press Enter. |
01:24 | The output is displayed. |
01:27 | Say, you need to look into people whose title is choudhury. |
01:32 | The problem is, different people spell their titles in different way. |
01:38 | So, what is the solution? |
01:41 | In such cases, we can use hyphen e option with hyphen i. |
01:47 | Type: grep space hyphen ie space within double quotes chaudhury ('c' 'h' 'a' 'u' 'd' 'h' 'u' 'r' 'y') after the quotes space hyphen ie space within double quotes chowdhari ('c' 'h' 'o' 'w' 'd' 'h' 'a' 'r' 'i') after the quotes space grepdemo.txt. |
02:11 | Press Enter. |
02:14 | The output is displayed. |
02:16 | But, there can be many other ways in which we can write the names. |
02:22 | How many hyphen e options can we give? |
02:26 | Obviously, there needs to be a better way and that way is through Regular expressions. |
02:33 | A 'regular expression' provides a concise and flexible means for matching strings of text |
02:41 | such as particular characters, words or patterns of characters. |
02:47 | There are a number of regular expression characters. |
02:51 | Let us see them one by one. |
02:54 | The character class- |
02:56 | It allows us to specify a group of characters within a pair of square brackets. |
03:03 | Only one out of this group of characters is matched. |
03:07 | Eg. [abc] would mean that this regular expression matches either a or b or c. |
03:17 | To match chaudhury, we may type at the prompt: |
03:22 | grep space hyphen i space within double quotes ch opening square-bracket ao closing square-bracket opening square-bracket uw closing square-bracket dh opening square-bracket ua closing square-bracket r opening square- bracket yi closing square-bracket after the double quotes space grepdemo.txt |
03:53 | Press Enter. |
03:55 | The output is displayed. |
03:59 | It still does not match choudhuree with double e. |
04:02 | If we want to specify a large range then we write: |
04:07 | First letter dash last letter of the range. |
04:13 | Suppose we like to match any digit, we simply write [0-9]. |
04:20 | One out of this group of characters is matched. |
04:24 | The asterisk: The asterisk refers to 0 or more occurrences of the immediately preceding character. |
04:33 | For example, ab asterisk can match a,ab,abb,abbb etc. |
04:43 | So, to match the students name whose name is Mira |
04:47 | We type at the prompt: |
04:50 | grep space hyphen i space within double quotes m opening square-bracket ei closing square bracket asterisk r a a asterisk after the quotes space grepdemo.txt |
05:11 | Press Enter. |
05:13 | The output is displayed. |
05:16 | The dot regular-expression matches any one character. |
05:21 | Say, we want to search any words that are 4 letters long and starts with M. |
05:27 | We would simply type: |
05:30 | grep space within double quotes M... space after the quotes space grepdemo.txt |
05:43 | Press Enter. |
05:45 | The output is displayed. |
05:47 | Here, the space within the quotes is important as it would match 5 or more letter words. |
05:56 | We may be specific about where in the line we want to search for our pattern. |
06:01 | It may be at the beginning of the line. |
06:04 | For that, we have the caret sign. |
06:07 | Now, if we want to get those entries whose roll-numbers start with A. |
06:13 | We know that roll is the first field in the file. |
06:18 | We type at the prompt: grep space within double quotes caret-sign A after the quotes grepdemo.txt |
06:29 | Press Enter. |
06:31 | The output is displayed. |
06:34 | Similarly, to match a pattern at the end of the file, we have the dollar sign. |
06:40 | To find stipends between 7000 to 8999, we have to write: |
06:49 | grep space within double quotes opening square bracket 78 closing square bracket ... dollar sign after the quotes space grepdemo.txt |
07:05 | Press Enter . |
07:07 | The output is displayed. |
07:10 | This brings us to the end of this tutorial. |
07:13 | Let us summarize. |
07:15 | In this tutorial, we learnt: |
07:17 | To match more than one pattern |
07:20 | To check a word that has different spelling |
07:23 | Character class The use of asterisk |
07:27 | To match any one character using dot |
07:31 | To match a pattern at the beginning of the file |
07:35 | To match a pattern at the end of the file. |
07:39 | As an assignment, list those entries that are 5 letters long and starts with 'Y'. |
07:46 | Watch the video available at the link shown below. |
07:50 | It summarizes the Spoken Tutorial project |
07:53 | If you do not have good bandwidth, you can download and watch it. |
07:59 | The Spoken Tutorial project team: conducts workshops using spoken tutorials. |
08:04 | Gives certificates to those who pass an online test. |
08:08 | For more details, please write to contact@spoken-tutorial.org |
08:14 | Spoken Tutorial Project is a part of the Talk to a Teacher project. |
08:19 | It is supported by the National Mission on Education through ICT, MHRD, Government of India. |
08:26 | More information on this mission is available at the link shown below : http://spoken-tutorial.org\NMEICT-Intro |
08:32 | The script has been contributed by Anirban and Sachin. |
08:36 | This is Ashwini Patil from IIT Bombay, signing off. Thank you for joining. |