Unix / Linux search command utility#


grep [options] regexp  [file...]


	-v	show lines that don't match instead of lines that match
	-H	print file names with matches
	-i	ignore case
	-E      enable extended regular expressions
	-c      print count only
	-l      just print the names of files that have matches
	-n      print line numbers
	-r      recurse into sub-directories
	-a      treat files as ascii

Extended regular expressions (i.e. -E). Those allowed in basic, non-extended mode too are marked with (B):#

Matching characters

	.	match any character (B)
	^	matches beginning of line (B)
	$	matches end of line (B)
	[abc]	matches 'a', 'b', or 'c' (B)
	[^abc]	matches anything except 'a', 'b', or 'c' (B)
	[a-e]	range match, same as [abcde] (B)
	[[:x:]]	match pre-defined class of characters as follows: (B)
	\w	same as [[:alnum:]]
	\W	same as [^[:alnum:]]
	\X      if X is a regular expression character then \X will cause a
	        match with the actual character and not the special meaning
	        of the character

Repeating characters

	*	preceding item matched zero or more times (B)
	?	preceding item matched 0 or 1 time
	+	preceding item matched one or more times
Grouping and Referencing
        ()      groups are surrounded with parenthesis 
        \n      backslash with a number n references the n'th grouping


        e1|e2   matches expression e1 OR e2

Add new attachment

Only authorized users are allowed to upload new attachments.
« This page (revision-8) was last changed on 05-Feb-2019 09:20 by Administrator