Our final example find all filenames starting with purchase but ending with db:Ī dot (.) has a special meaning in regex, i.e. Next I need to find all filenames starting with purchase and followed by another character: Let us find all filenames starting with purchase, type: character (period, or dot) matches any one character. $ grep -E -i '^(linux|unix)' filename How to match single characters # Same as above by passing the '-E' to the grep # The following will match word Linux or UNIX in any case using the egrep command: The PATTERN in last example, used as an extended regular expression. Let us try to search two words ‘vivek’ or ‘raj’ in any case: Next, search for a word named ‘vivek’ in any case (i.e. Sample outputs: vivek:x:1000:1000:Vivek Gite,:/home/vivek:/bin/bash Search for a word named ‘vivek’ in the /etc/passwd file: The grep understands three different types of regular expression syntax as follows:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |