![Mass effect andromeda automute](https://loka.nahovitsyn.com/148.jpg)
To display all the lines that starts with both upper and lower case letters, we use: $ egrep '^|' file.txt Since grep is case-sensitive, it is not going to find lines that starts with uppercase letters in the given range. Please note that I have used square bracket ([) to search for the range of words. Everything else will be omitted from the result. That means, we will get the lines that start with l, m, n, o, p, q, r, s, t, and u. Similarly, We can search for the lines that start with any character range between "l" to "u". Please note that the normal grep command can't do this. See? We have got all of the words that starts with either "l" or "o". Hence, our command for the above query will be: $ egrep '^(l|o)' file.txt Remember we use caret symbol (^) to search words at the beginning of line. However, It provides some additional functionalities, such as using complicated regex, than the normal grep command does out of the box.įor instance, we can search for any words that start with either "l" or "o". It will do all the things that grep will do. Egrep command examplesĮgrep stands for extended grep. Let us go ahead and learn the other two variants, namely egrep and fgrep. You should now have a basic understanding of grep usage. (dot).įor example, let us search for any word that has "n" in the file. $ grep x$ file.txtĪlso, you can find the words that contains any character using. Similarly, we can search for the words that ends with a particular letter(s), for example "x", like below.
![grep special characters grep special characters](https://colecandoo.com/wp-content/uploads/2019/11/diary11.png)
To search for the words that matches the pattern "tech" at the beginning of the line in a file, run: $ grep ^tech file.txt This is where special characters comes in handy. You don't want to display all the words that contains the string, but only the words that have the string "tech" at the beginning. $ grep tech file.txtīut what if you just wanted to search for the lines that only start with the word "tech". You know already, we can search for the words that contains the string "tech" like below.
GREP SPECIAL CHARACTERS HOW TO
Let me show you an example, so you can understand where and how to use those special characters.
![grep special characters grep special characters](https://i.stack.imgur.com/6qQ7J.png)
Finds Walden in any file in any subfolder of ~/Documents.įinds only live does not find liver, lives, lived, and so on.įinds files containing Walden, but returns only a list of file names.
![Mass effect andromeda automute](https://loka.nahovitsyn.com/148.jpg)