Regular Expressions - Linux Tutorial 10

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome to the video tutorial on regular expressions in Linux so what are regular expressions well they are special characters no not these yes which help search data and match complex patterns regular expressions are shortened as reg exp or res X some of the commonly used commands with regular expressions are TR sed VI and gr e P these are some of the basic projects let us learn their practical use let's consider this sample file now we will use the GRE P command to look for lines containing the letter A let's use a regular expression now using the cat symbol we will search for the content that starts with the character a the caret matches the start of a string this is why only lines that start with the character a are filtered lines which do not contain the character a at the start arek note let us look into another example here we will look for the character T in the same file sample now let us select only those lines which end with the character T for this we will need to use this regular expression which matches the end of the strength this is how we can use regular expressions moving on to the interval regular expressions they tell us about the number of occurrences of a character or string they are [Music] so if we use the first expression it will match the preceding character appearing and times exactly let us write on terminal let us filter out all the lines that contain the character P now if we want to check the character P appearing exactly two times in a string one after the other for this the syntax would be which will give us this result it should be noted here that you need to add - capital e with these regular expressions the next is the extended regular expressions these contain combinations of more than one expressions some of them are so if we use the backward slash with a plus sign it will match one or more occurrence of the previous character let us learn there practical use here we have searched for the character T suppose we want to filter out lines where character a precedes character T we would have to use the command like sense [Music] running this command would give us this result this is how we can use the extended regular expressions the syntax for base expansion is either a sequence or a comma separated list of items inside curly braces the starting and end of items in a sequence are separated by two periods let us go through some of the examples here we would use the echo command to create strings using the brace expansion [Music] another example of the same would be this would create a strength from A to Z one more example would be this an advanced example of the brace expansion is this [Music] this is how we can create strength using the base expansion to recap what we have learned reading expressions are a set of characters used to check patterns and strengths they're also called read exp and regex it is important to learn regular expressions for writing scripts some basic regular expressions are the period symbol replaces any character the caret matches the start of a strain the dollar sign matches the end of earth strength some extended regular expressions are here the backslash used with the plus sign matches one or more occurrence of the previous character the backslash used with a question mark matches zero or one occurrence of the previous character some interval regular expressions are here the N in the curly braces matches the preceding character appearing n times exactly in the second expression the N and M and the curly braces match preceding character appearing n times but not more than m and the last total expression displayed here matches the preceding character only when it appears and times or more the brace expansion is used to generate strings it helps in creating multiple strings out of one thanks for watching this tutorial I hope to see you in the next one
Info
Channel: Guru99
Views: 114,291
Rating: 4.9058824 out of 5
Keywords: linux tutorial, regular expressions, javascript regular expressions, java regular expressions, linux - regular expressions, unix, regular expression, guru99 linux, guru99
Id: mpyCeSvGh-M
Channel Id: undefined
Length: 5min 7sec (307 seconds)
Published: Wed Feb 06 2013
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.