Difference between revisions of "BOSS-Linux/C3/More-on-grep-command/English-timed"
From Script | Spoken-Tutorial
PoojaMoolya (Talk | contribs) (Created page with "{| border =1 | '''Time''' | '''Narration''' |- | 00:01 | Welcome to the spoken tutorial on more on '''grep''' |- | 00:05 | In this tutorial we will learn |- | 00:0...") |
PoojaMoolya (Talk | contribs) |
||
Line 1: | Line 1: | ||
+ | |||
{| border =1 | {| border =1 | ||
| '''Time''' | | '''Time''' | ||
Line 13: | Line 14: | ||
|- | |- | ||
| 00:07 | | 00:07 | ||
− | |some more | + | |some more grep commands. |
|- | |- | ||
Line 25: | Line 26: | ||
|- | |- | ||
| 00:16 | | 00:16 | ||
− | |'''Linux''' Operating System''' and | + | |'''Ubuntu Linux''' version 12.04''' Operating System''' and |
|- | |- | ||
Line 32: | Line 33: | ||
|- | |- | ||
− | | 00: | + | | 00:24 |
|Please note,''' GNU bash''' version 4 or above is recommended to practice this tutorial. | |Please note,''' GNU bash''' version 4 or above is recommended to practice this tutorial. | ||
|- | |- | ||
− | | 00: | + | | 00:31 |
| As prerequisites | | As prerequisites | ||
|- | |- | ||
− | | 00: | + | | 00:33 |
|You should know Basics of linux terminal. | |You should know Basics of linux terminal. | ||
|- | |- | ||
− | | 00: | + | | 00:36 |
− | |You should be aware of | + | |You should be aware of grep. |
|- | |- | ||
− | | 00: | + | | 00:39 |
|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 | ||
|- | |- | ||
− | | 00: | + | | 00:45 |
| We can match more than one patterns as well. | | We can match more than one patterns as well. | ||
|- | |- | ||
− | | 00: | + | | 00:49 |
|Then we have to use the '''hyphen e''' option. | |Then we have to use the '''hyphen e''' option. | ||
|- | |- | ||
− | | 00: | + | | 00:53 |
− | |I will use the same file | + | |I will use the same file grepdemo.txt |
|- | |- | ||
− | | 00: | + | | 00:58 |
|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'''. | ||
|- | |- | ||
− | | 01: | + | | 01:05 |
|We need to type on the terminal: | |We need to type on the terminal: | ||
|- | |- | ||
| 01:07 | | 01:07 | ||
− | |'''grep''' space '''hyphen e''' space within double quotes '''electronics''' after the quotes space '''hyphen e''' space | + | |'''grep''' space '''hyphen e''' space within double quotes '''electronics''' after the quotes space '''hyphen e''' space in double quotes '''civil''' after the quotes space '''grepdemo.txt''' |
|- | |- | ||
− | | 01: | + | | 01:24 |
− | | | + | |'''Press Enter.''' |
|- | |- | ||
− | | 01: | + | | 01:25 |
|The output is displayed. | |The output is displayed. | ||
|- | |- | ||
− | | 01: | + | | 01:28 |
| Say you need to look into people whose title is '''choudhury'''. | | Say you need to look into people whose title is '''choudhury'''. | ||
|- | |- | ||
− | | 01: | + | | 01:33 |
|The problem is different peoples spell their titles in different way. | |The problem is different peoples spell their titles in different way. | ||
Line 96: | Line 97: | ||
|- | |- | ||
− | | 01: | + | | 01:42 |
|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: | + | | 01:48 |
− | |Type: '''grep''' space '''hyphen ie''' space in double quotes '''chaudhury''' | + | |Type: |
+ | '''grep''' space '''hyphen ie''' space in double quotes '''chaudhury''' after the quotes space '''hyphen ie''' space in double quotes '''chowdhari''' after the quotes space '''grepdemo.txt''' | ||
|- | |- | ||
− | | 02: | + | | 02:12 |
− | | | + | |'''Press Enter.''' |
|- | |- | ||
Line 116: | Line 118: | ||
|- | |- | ||
− | | 02: | + | | 02:23 |
|How many '''hyphen e''' options can we give. | |How many '''hyphen e''' options can we give. | ||
Line 136: | Line 138: | ||
|- | |- | ||
− | | 02: | + | | 02:52 |
|Let us see them one by one. | |Let us see them one by one. | ||
|- | |- | ||
− | | 02: | + | | 02:55 |
| The character class. | | The character class. | ||
|- | |- | ||
− | | 02: | + | | 02:57 |
|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 152: | Line 154: | ||
|- | |- | ||
− | | 03: | + | | 03:08 |
|Eg. [abc] would mean that this regular expression matches either a or b or c. | |Eg. [abc] would mean that this regular expression matches either a or b or c. | ||
|- | |- | ||
− | | 03: | + | | 03:18 |
| To match '''chaudhury''' we may type at the prompt | | To match '''chaudhury''' we may type at the prompt | ||
|- | |- | ||
− | | 03: | + | | 03:23 |
|'''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''' | ||
|- | |- | ||
− | | 03: | + | | 03:54 |
− | | | + | |'''Press Enter.''' |
|- | |- | ||
− | | 03: | + | | 03:56 |
|The output is displayed. | |The output is displayed. | ||
Line 176: | Line 178: | ||
|- | |- | ||
− | | 04: | + | | 04:03 |
| If we want to specify a large range then we write: | | If we want to specify a large range then we write: | ||
|- | |- | ||
− | | 04: | + | | 04:08 |
|First letter dash last letter of the range | |First letter dash last letter of the range | ||
Line 200: | Line 202: | ||
|- | |- | ||
− | | 04: | + | | 04:44 |
| So to match the students name whose name is '''Mira''' | | So to match the students name whose name is '''Mira''' | ||
|- | |- | ||
− | | 04: | + | | 04:48 |
|We type at the prompt: | |We type at the prompt: | ||
|- | |- | ||
− | | 04: | + | | 04:51 |
|'''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''' | |'''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: | + | | 05:12 |
− | | | + | |'''Press Enter.''' |
|- | |- | ||
− | | 05: | + | | 05:14 |
|The output is displayed. | |The output is displayed. | ||
Line 228: | Line 230: | ||
|- | |- | ||
− | | 05: | + | | 05:29 |
|We would simply type | |We would simply type | ||
|- | |- | ||
− | | 05: | + | | 05:31 |
|'''grep''' space within double quotes '''M...''' space after the quotes space '''grepdemo.txt''' | |'''grep''' space within double quotes '''M...''' space after the quotes space '''grepdemo.txt''' | ||
|- | |- | ||
− | | 05: | + | | 05:44 |
− | | | + | |'''Press Enter.''' |
|- | |- | ||
− | | 05: | + | | 05:46 |
|The output is displayed. | |The output is displayed. | ||
|- | |- | ||
− | | 05: | + | | 05:48 |
|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 264: | Line 266: | ||
|- | |- | ||
− | | 06: | + | | 06:14 |
|We know that roll is the first field in the file. | |We know that roll is the first field in the file. | ||
|- | |- | ||
− | | 06: | + | | 06:19 |
|We type at the prompt: '''grep ''' within double quotes '''caret sign A''' after the quotes '''grepdemo.txt''' | |We type at the prompt: '''grep ''' within double quotes '''caret sign A''' after the quotes '''grepdemo.txt''' | ||
|- | |- | ||
| 06:29 | | 06:29 | ||
− | | | + | |'''Press Enter.''' |
|- | |- | ||
− | | 06: | + | | 06:32 |
|The output is displayed. | |The output is displayed. | ||
|- | |- | ||
− | | 06: | + | | 06:35 |
| Similarly to match a pattern at the end of the file, we have the '''dollar sign.''' | | Similarly to match a pattern at the end of the file, we have the '''dollar sign.''' | ||
|- | |- | ||
− | | 06: | + | | 06:41 |
|To find stipends between '''7000 '''to '''8999''' we have to write: | |To find stipends between '''7000 '''to '''8999''' we have to write: | ||
|- | |- | ||
− | | 06: | + | | 06:50 |
|'''grep''' space within double quotes'''opening square bracket 78 closing square bracket '''...'''dollar sign''' after the quotes space '''grepdemo.txt''' | |'''grep''' space within double quotes'''opening square bracket 78 closing square bracket '''...'''dollar sign''' after the quotes space '''grepdemo.txt''' | ||
|- | |- | ||
− | | 07: | + | | 07:06 |
− | | | + | |'''Press Enter ''' |
|- | |- | ||
− | | 07: | + | | 07:08 |
|The output is displayed. | |The output is displayed. | ||
|- | |- | ||
− | | 07: | + | | 07:11 |
|This brings us to the end of this tutorial. | |This brings us to the end of this tutorial. | ||
Line 308: | Line 310: | ||
|- | |- | ||
− | | 07: | + | | 07:16 |
| In this tutorial we learnt, | | In this tutorial we learnt, | ||
|- | |- | ||
− | | 07: | + | | 07:18 |
|To match more than one pattern | |To match more than one pattern | ||
Line 320: | Line 322: | ||
|- | |- | ||
− | | 07: | + | | 07:24 |
|Character class | |Character class | ||
|- | |- | ||
− | | 07: | + | | 07:25 |
|The use of '''asterisk''' | |The use of '''asterisk''' | ||
|- | |- | ||
− | | 07: | + | | 07:28 |
|To match any one character using '''dot''' | |To match any one character using '''dot''' | ||
|- | |- | ||
− | | 07: | + | | 07:32 |
|To match a pattern at the beginning of the file | |To match a pattern at the beginning of the file | ||
Line 340: | Line 342: | ||
|- | |- | ||
− | | 07: | + | | 07:40 |
− | | As an assignment, List those entries that are 5 letters long and starts with Y. | + | | As an assignment, |
+ | List those entries that are 5 letters long and starts with Y. | ||
|- | |- | ||
− | | 07: | + | | 07:48 |
| Watch the video available at the link shown below | | Watch the video available at the link shown below | ||
|- | |- | ||
− | | 07: | + | | 07:51 |
|It summarises the Spoken Tutorial project | |It summarises the Spoken Tutorial project | ||
|- | |- | ||
− | | 07: | + | | 07:54 |
|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 | ||
Line 360: | Line 363: | ||
|- | |- | ||
− | | 08: | + | | 08:05 |
|Gives certificates to those who pass an online test | |Gives certificates to those who pass an online test | ||
Line 368: | Line 371: | ||
|- | |- | ||
− | | 08: | + | | 08:15 |
| 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: | + | | 08:20 |
|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 | ||
Revision as of 13:02, 12 February 2015
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 grep commands. |
00:10 | Through some examples |
00:13 | To record this tutorial, I am using |
00:16 | Ubuntu Linux version 12.04 Operating System and |
00:20 | GNU BASH version 4.2.24 |
00:24 | Please note, GNU bash version 4 or above is recommended to practice this tutorial. |
00:31 | As prerequisites |
00:33 | You should know Basics of linux terminal. |
00:36 | You should be aware of grep. |
00:39 | For relevant tutorials please visit our website which is as shown: http://spoken-tutorial.org |
00:45 | We can match more than one patterns as well. |
00:49 | Then we have to use the hyphen e option. |
00:53 | I will use the same file grepdemo.txt |
00:58 | Say we want to find information for those who are either in civil or electronics. |
01:05 | 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 in double quotes civil after the quotes space grepdemo.txt |
01:24 | Press Enter. |
01:25 | The output is displayed. |
01:28 | Say you need to look into people whose title is choudhury. |
01:33 | The problem is different peoples spell their titles in different way. |
01:38 | So what is the solution?. |
01:42 | In such cases we can use hyphen e option with hyphen i. |
01:48 | Type:
grep space hyphen ie space in double quotes chaudhury after the quotes space hyphen ie space in double quotes chowdhari after the quotes space grepdemo.txt |
02:12 | 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:23 | 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:52 | Let us see them one by one. |
02:55 | The character class. |
02:57 | 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:08 | Eg. [abc] would mean that this regular expression matches either a or b or c. |
03:18 | To match chaudhury we may type at the prompt |
03:23 | 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:54 | Press Enter. |
03:56 | The output is displayed. |
03:59 | It still does not match choudhuree with double e. |
04:03 | If we want to specify a large range then we write: |
04:08 | 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:44 | So to match the students name whose name is Mira |
04:48 | We type at the prompt: |
04:51 | 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:12 | Press Enter. |
05:14 | 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:29 | We would simply type |
05:31 | grep space within double quotes M... space after the quotes space grepdemo.txt |
05:44 | Press Enter. |
05:46 | The output is displayed. |
05:48 | 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 get those entries whose roll numbers start with A. |
06:14 | We know that roll is the first field in the file. |
06:19 | We type at the prompt: grep within double quotes caret sign A after the quotes grepdemo.txt |
06:29 | Press Enter. |
06:32 | The output is displayed. |
06:35 | Similarly to match a pattern at the end of the file, we have the dollar sign. |
06:41 | To find stipends between 7000 to 8999 we have to write: |
06:50 | grep space within double quotesopening square bracket 78 closing square bracket ...dollar sign after the quotes space grepdemo.txt |
07:06 | Press Enter |
07:08 | The output is displayed. |
07:11 | This brings us to the end of this tutorial. |
07:13 | Let us summarize. |
07:16 | In this tutorial we learnt, |
07:18 | To match more than one pattern |
07:20 | To check a word that has different spelling |
07:24 | Character class |
07:25 | The use of asterisk |
07:28 | To match any one character using dot |
07:32 | To match a pattern at the beginning of the file |
07:35 | To match a pattern at the end of the file |
07:40 | As an assignment,
List those entries that are 5 letters long and starts with Y. |
07:48 | Watch the video available at the link shown below |
07:51 | It summarises the Spoken Tutorial project |
07:54 | 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:05 | Gives certificates to those who pass an online test |
08:08 | For more details, please write to contact@spoken-tutorial.org |
08:15 | Spoken Tutorial Project is a part of the Talk to a Teacher project |
08:20 | 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 signning off. Thank you for joining. |