14dc88ebeSGabor Kovesdan.\" $FreeBSD$ 24dc88ebeSGabor Kovesdan.\" $OpenBSD: grep.1,v 1.38 2010/04/05 06:30:59 jmc Exp $ 34dc88ebeSGabor Kovesdan.\" Copyright (c) 1980, 1990, 1993 44dc88ebeSGabor Kovesdan.\" The Regents of the University of California. All rights reserved. 54dc88ebeSGabor Kovesdan.\" 64dc88ebeSGabor Kovesdan.\" Redistribution and use in source and binary forms, with or without 74dc88ebeSGabor Kovesdan.\" modification, are permitted provided that the following conditions 84dc88ebeSGabor Kovesdan.\" are met: 94dc88ebeSGabor Kovesdan.\" 1. Redistributions of source code must retain the above copyright 104dc88ebeSGabor Kovesdan.\" notice, this list of conditions and the following disclaimer. 114dc88ebeSGabor Kovesdan.\" 2. Redistributions in binary form must reproduce the above copyright 124dc88ebeSGabor Kovesdan.\" notice, this list of conditions and the following disclaimer in the 134dc88ebeSGabor Kovesdan.\" documentation and/or other materials provided with the distribution. 144dc88ebeSGabor Kovesdan.\" 3. Neither the name of the University nor the names of its contributors 154dc88ebeSGabor Kovesdan.\" may be used to endorse or promote products derived from this software 164dc88ebeSGabor Kovesdan.\" without specific prior written permission. 174dc88ebeSGabor Kovesdan.\" 184dc88ebeSGabor Kovesdan.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 194dc88ebeSGabor Kovesdan.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 204dc88ebeSGabor Kovesdan.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 214dc88ebeSGabor Kovesdan.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 224dc88ebeSGabor Kovesdan.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 234dc88ebeSGabor Kovesdan.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 244dc88ebeSGabor Kovesdan.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 254dc88ebeSGabor Kovesdan.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 264dc88ebeSGabor Kovesdan.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 274dc88ebeSGabor Kovesdan.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 284dc88ebeSGabor Kovesdan.\" SUCH DAMAGE. 294dc88ebeSGabor Kovesdan.\" 304dc88ebeSGabor Kovesdan.\" @(#)grep.1 8.3 (Berkeley) 4/18/94 314dc88ebeSGabor Kovesdan.\" 32*e9a67923SGabor Kovesdan.Dd September 19, 2009 334dc88ebeSGabor Kovesdan.Dt GREP 1 344dc88ebeSGabor Kovesdan.Os 354dc88ebeSGabor Kovesdan.Sh NAME 364dc88ebeSGabor Kovesdan.Nm grep , egrep , fgrep , 374dc88ebeSGabor Kovesdan.Nm zgrep , zegrep , zfgrep 384dc88ebeSGabor Kovesdan.Nd file pattern searcher 394dc88ebeSGabor Kovesdan.Sh SYNOPSIS 404dc88ebeSGabor Kovesdan.Nm grep 414dc88ebeSGabor Kovesdan.Bk -words 424dc88ebeSGabor Kovesdan.Op Fl abcdDEFGHhIiJLlmnOopqRSsUVvwxZ 434dc88ebeSGabor Kovesdan.Op Fl A Ar num 444dc88ebeSGabor Kovesdan.Op Fl B Ar num 454dc88ebeSGabor Kovesdan.Op Fl C Ns Op Ar num 464dc88ebeSGabor Kovesdan.Op Fl e Ar pattern 474dc88ebeSGabor Kovesdan.Op Fl f Ar file 484dc88ebeSGabor Kovesdan.Op Fl Fl binary-files Ns = Ns Ar value 494dc88ebeSGabor Kovesdan.Op Fl Fl color Ns Op = Ns Ar when 504dc88ebeSGabor Kovesdan.Op Fl Fl colour Ns Op = Ns Ar when 514dc88ebeSGabor Kovesdan.Op Fl Fl context Ns Op = Ns Ar num 524dc88ebeSGabor Kovesdan.Op Fl Fl label 534dc88ebeSGabor Kovesdan.Op Fl Fl line-buffered 544dc88ebeSGabor Kovesdan.Op Fl Fl null 554dc88ebeSGabor Kovesdan.Op Ar pattern 564dc88ebeSGabor Kovesdan.Op Ar 574dc88ebeSGabor Kovesdan.Ek 584dc88ebeSGabor Kovesdan.Sh DESCRIPTION 594dc88ebeSGabor KovesdanThe 604dc88ebeSGabor Kovesdan.Nm grep 614dc88ebeSGabor Kovesdanutility searches any given input files, 624dc88ebeSGabor Kovesdanselecting lines that match one or more patterns. 634dc88ebeSGabor KovesdanBy default, a pattern matches an input line if the regular expression 644dc88ebeSGabor Kovesdan(RE) in the pattern matches the input line 654dc88ebeSGabor Kovesdanwithout its trailing newline. 664dc88ebeSGabor KovesdanAn empty expression matches every line. 674dc88ebeSGabor KovesdanEach input line that matches at least one of the patterns is written 684dc88ebeSGabor Kovesdanto the standard output. 694dc88ebeSGabor Kovesdan.Pp 704dc88ebeSGabor Kovesdan.Nm grep 714dc88ebeSGabor Kovesdanis used for simple patterns and 724dc88ebeSGabor Kovesdanbasic regular expressions 734dc88ebeSGabor Kovesdan.Pq BREs ; 744dc88ebeSGabor Kovesdan.Nm egrep 754dc88ebeSGabor Kovesdancan handle extended regular expressions 764dc88ebeSGabor Kovesdan.Pq EREs . 774dc88ebeSGabor KovesdanSee 784dc88ebeSGabor Kovesdan.Xr re_format 7 794dc88ebeSGabor Kovesdanfor more information on regular expressions. 804dc88ebeSGabor Kovesdan.Nm fgrep 814dc88ebeSGabor Kovesdanis quicker than both 824dc88ebeSGabor Kovesdan.Nm grep 834dc88ebeSGabor Kovesdanand 844dc88ebeSGabor Kovesdan.Nm egrep , 854dc88ebeSGabor Kovesdanbut can only handle fixed patterns 864dc88ebeSGabor Kovesdan(i.e. it does not interpret regular expressions). 874dc88ebeSGabor KovesdanPatterns may consist of one or more lines, 884dc88ebeSGabor Kovesdanallowing any of the pattern lines to match a portion of the input. 894dc88ebeSGabor Kovesdan.Pp 904dc88ebeSGabor Kovesdan.Nm zgrep , 914dc88ebeSGabor Kovesdan.Nm zegrep , 924dc88ebeSGabor Kovesdanand 934dc88ebeSGabor Kovesdan.Nm zfgrep 944dc88ebeSGabor Kovesdanact like 954dc88ebeSGabor Kovesdan.Nm grep , 964dc88ebeSGabor Kovesdan.Nm egrep , 974dc88ebeSGabor Kovesdanand 984dc88ebeSGabor Kovesdan.Nm fgrep , 994dc88ebeSGabor Kovesdanrespectively, but accept input files compressed with the 1004dc88ebeSGabor Kovesdan.Xr compress 1 1014dc88ebeSGabor Kovesdanor 1024dc88ebeSGabor Kovesdan.Xr gzip 1 1034dc88ebeSGabor Kovesdancompression utilities. 1044dc88ebeSGabor Kovesdan.Pp 1054dc88ebeSGabor KovesdanThe following options are available: 1064dc88ebeSGabor Kovesdan.Bl -tag -width indent 1074dc88ebeSGabor Kovesdan.It Fl A Ar num , Fl Fl after-context Ns = Ns Ar num 1084dc88ebeSGabor KovesdanPrint 1094dc88ebeSGabor Kovesdan.Ar num 1104dc88ebeSGabor Kovesdanlines of trailing context after each match. 1114dc88ebeSGabor KovesdanSee also the 1124dc88ebeSGabor Kovesdan.Fl B 1134dc88ebeSGabor Kovesdanand 1144dc88ebeSGabor Kovesdan.Fl C 1154dc88ebeSGabor Kovesdanoptions. 1164dc88ebeSGabor Kovesdan.It Fl a , Fl Fl text 1174dc88ebeSGabor KovesdanTreat all files as ASCII text. 1184dc88ebeSGabor KovesdanNormally 1194dc88ebeSGabor Kovesdan.Nm 1204dc88ebeSGabor Kovesdanwill simply print 1214dc88ebeSGabor Kovesdan.Dq Binary file ... matches 1224dc88ebeSGabor Kovesdanif files contain binary characters. 1234dc88ebeSGabor KovesdanUse of this option forces 1244dc88ebeSGabor Kovesdan.Nm 1254dc88ebeSGabor Kovesdanto output lines matching the specified pattern. 1264dc88ebeSGabor Kovesdan.It Fl B Ar num , Fl Fl before-context Ns = Ns Ar num 1274dc88ebeSGabor KovesdanPrint 1284dc88ebeSGabor Kovesdan.Ar num 1294dc88ebeSGabor Kovesdanlines of leading context before each match. 1304dc88ebeSGabor KovesdanSee also the 1314dc88ebeSGabor Kovesdan.Fl A 1324dc88ebeSGabor Kovesdanand 1334dc88ebeSGabor Kovesdan.Fl C 1344dc88ebeSGabor Kovesdanoptions. 1354dc88ebeSGabor Kovesdan.It Fl b , Fl Fl byte-offset 1364dc88ebeSGabor KovesdanThe offset in bytes of a matched pattern is 1374dc88ebeSGabor Kovesdandisplayed in front of the respective matched line. 1384dc88ebeSGabor Kovesdan.It Fl C Ns Op Ar num , Fl Fl context Ns = Ns Ar num 1394dc88ebeSGabor KovesdanPrint 1404dc88ebeSGabor Kovesdan.Ar num 1414dc88ebeSGabor Kovesdanlines of leading and trailing context surrounding each match. 1424dc88ebeSGabor KovesdanThe default is 2 and is equivalent to 1434dc88ebeSGabor Kovesdan.Fl A 1444dc88ebeSGabor Kovesdan.Ar 2 1454dc88ebeSGabor Kovesdan.Fl B 1464dc88ebeSGabor Kovesdan.Ar 2 . 1474dc88ebeSGabor KovesdanNote: 1484dc88ebeSGabor Kovesdanno whitespace may be given between the option and its argument. 1494dc88ebeSGabor Kovesdan.It Fl c , Fl Fl count 1504dc88ebeSGabor KovesdanOnly a count of selected lines is written to standard output. 1514dc88ebeSGabor Kovesdan.It Fl Fl colour Ns = Ns Op Ar when , Fl Fl color Ns = Ns Op Ar when 1524dc88ebeSGabor KovesdanMark up the matching text with the expression stored in 1534dc88ebeSGabor Kovesdan.Ev GREP_COLOR 1544dc88ebeSGabor Kovesdanenvironment variable. 1554dc88ebeSGabor KovesdanThe possible values of when can be `never', `always' or `auto'. 1564dc88ebeSGabor Kovesdan.It Fl D Ar action , Fl Fl devices Ns = Ns Ar action 1574dc88ebeSGabor KovesdanSpecify the demanded action for devices, FIFOs and sockets. 1584dc88ebeSGabor KovesdanThe default action is `read', which means, that they are read 1594dc88ebeSGabor Kovesdanas if they were normal files. 1604dc88ebeSGabor KovesdanIf the action is set to `skip', devices will be silently skipped. 1614dc88ebeSGabor Kovesdan.It Fl d Ar action , Fl Fl directories Ns = Ns Ar action 1624dc88ebeSGabor KovesdanSpecify the demanded action for directories. 1634dc88ebeSGabor KovesdanIt is `read' by default, which means that the directories 1644dc88ebeSGabor Kovesdanare read in the same manner as normal files. 1654dc88ebeSGabor KovesdanOther possible values are `skip' to silently ignore the 1664dc88ebeSGabor Kovesdandirectories, and `recurse' to read them recursively, which 1674dc88ebeSGabor Kovesdanhas the same effect as the 1684dc88ebeSGabor Kovesdan.Fl R 1694dc88ebeSGabor Kovesdanand 1704dc88ebeSGabor Kovesdan.Fl r 1714dc88ebeSGabor Kovesdanoption. 1724dc88ebeSGabor Kovesdan.It Fl E , Fl Fl extended-regexp 1734dc88ebeSGabor KovesdanInterpret 1744dc88ebeSGabor Kovesdan.Ar pattern 1754dc88ebeSGabor Kovesdanas an extended regular expression 1764dc88ebeSGabor Kovesdan(i.e. force 1774dc88ebeSGabor Kovesdan.Nm grep 1784dc88ebeSGabor Kovesdanto behave as 1794dc88ebeSGabor Kovesdan.Nm egrep ) . 1804dc88ebeSGabor Kovesdan.It Fl e Ar pattern , Fl Fl regexp Ns = Ns Ar pattern 1814dc88ebeSGabor KovesdanSpecify a pattern used during the search of the input: 1824dc88ebeSGabor Kovesdanan input line is selected if it matches any of the specified patterns. 1834dc88ebeSGabor KovesdanThis option is most useful when multiple 1844dc88ebeSGabor Kovesdan.Fl e 1854dc88ebeSGabor Kovesdanoptions are used to specify multiple patterns, 1864dc88ebeSGabor Kovesdanor when a pattern begins with a dash 1874dc88ebeSGabor Kovesdan.Pq Sq - . 1884dc88ebeSGabor Kovesdan.It Fl Fl exclude 1894dc88ebeSGabor KovesdanIf 1904dc88ebeSGabor Kovesdan.Fl R 1914dc88ebeSGabor Kovesdanis specified, it excludes files matching the given 1924dc88ebeSGabor Kovesdanfilename pattern. 1934dc88ebeSGabor Kovesdan.It Fl Fl exclude-dir 1944dc88ebeSGabor KovesdanIf 1954dc88ebeSGabor Kovesdan.Fl R 1964dc88ebeSGabor Kovesdanis specified, it excludes directories matching the 1974dc88ebeSGabor Kovesdangiven filename pattern. 1984dc88ebeSGabor Kovesdan.It Fl F , Fl Fl fixed-strings 1994dc88ebeSGabor KovesdanInterpret 2004dc88ebeSGabor Kovesdan.Ar pattern 2014dc88ebeSGabor Kovesdanas a set of fixed strings 2024dc88ebeSGabor Kovesdan(i.e. force 2034dc88ebeSGabor Kovesdan.Nm grep 2044dc88ebeSGabor Kovesdanto behave as 2054dc88ebeSGabor Kovesdan.Nm fgrep ) . 2064dc88ebeSGabor Kovesdan.It Fl f Ar file , Fl Fl file Ns = Ns Ar file 2074dc88ebeSGabor KovesdanRead one or more newline separated patterns from 2084dc88ebeSGabor Kovesdan.Ar file . 2094dc88ebeSGabor KovesdanEmpty pattern lines match every input line. 2104dc88ebeSGabor KovesdanNewlines are not considered part of a pattern. 2114dc88ebeSGabor KovesdanIf 2124dc88ebeSGabor Kovesdan.Ar file 2134dc88ebeSGabor Kovesdanis empty, nothing is matched. 2144dc88ebeSGabor Kovesdan.It Fl G , Fl Fl basic-regexp 2154dc88ebeSGabor KovesdanInterpret 2164dc88ebeSGabor Kovesdan.Ar pattern 2174dc88ebeSGabor Kovesdanas a basic regular expression 2184dc88ebeSGabor Kovesdan(i.e. force 2194dc88ebeSGabor Kovesdan.Nm grep 2204dc88ebeSGabor Kovesdanto behave as traditional 2214dc88ebeSGabor Kovesdan.Nm grep ) . 2224dc88ebeSGabor Kovesdan.It Fl H 2234dc88ebeSGabor KovesdanAlways print filename headers with output lines. 2244dc88ebeSGabor Kovesdan.It Fl h , Fl Fl no-filename 2254dc88ebeSGabor KovesdanNever print filename headers 2264dc88ebeSGabor Kovesdan.Pq i.e. filenames 2274dc88ebeSGabor Kovesdanwith output lines. 2284dc88ebeSGabor Kovesdan.It Fl Fl help 2294dc88ebeSGabor KovesdanPrint a brief help message. 2304dc88ebeSGabor Kovesdan.It Fl I 2314dc88ebeSGabor KovesdanIgnore binary files. 2324dc88ebeSGabor KovesdanThis option is equivalent to 2334dc88ebeSGabor Kovesdan.Fl Fl binary-file Ns = Ns Ar without-match 2344dc88ebeSGabor Kovesdanoption. 2354dc88ebeSGabor Kovesdan.It Fl i , Fl Fl ignore-case 2364dc88ebeSGabor KovesdanPerform case insensitive matching. 2374dc88ebeSGabor KovesdanBy default, 2384dc88ebeSGabor Kovesdan.Nm grep 2394dc88ebeSGabor Kovesdanis case sensitive. 2404dc88ebeSGabor Kovesdan.It Fl Fl include 2414dc88ebeSGabor KovesdanIf 2424dc88ebeSGabor Kovesdan.Fl R 2434dc88ebeSGabor Kovesdanis specified, it includes the files matching the 2444dc88ebeSGabor Kovesdangiven filename pattern. 2454dc88ebeSGabor Kovesdan.It Fl Fl include-dir 2464dc88ebeSGabor KovesdanIf 2474dc88ebeSGabor Kovesdan.Fl R 2484dc88ebeSGabor Kovesdanis specified, it includes the directories matching the 2494dc88ebeSGabor Kovesdangiven filename pattern. 2504dc88ebeSGabor Kovesdan.It Fl J, Fl Fl bz2decompress 2514dc88ebeSGabor KovesdanDecompress the 2524dc88ebeSGabor Kovesdan.Xr bzip2 1 2534dc88ebeSGabor Kovesdancompressed file before looking for the text. 2544dc88ebeSGabor Kovesdan.It Fl L , Fl Fl files-without-match 2554dc88ebeSGabor KovesdanOnly the names of files not containing selected lines are written to 2564dc88ebeSGabor Kovesdanstandard output. 2574dc88ebeSGabor KovesdanPathnames are listed once per file searched. 2584dc88ebeSGabor KovesdanIf the standard input is searched, the string 2594dc88ebeSGabor Kovesdan.Dq (standard input) 2604dc88ebeSGabor Kovesdanis written. 2614dc88ebeSGabor Kovesdan.It Fl l , Fl Fl files-with-matches 2624dc88ebeSGabor KovesdanOnly the names of files containing selected lines are written to 2634dc88ebeSGabor Kovesdanstandard output. 2644dc88ebeSGabor Kovesdan.Nm grep 2654dc88ebeSGabor Kovesdanwill only search a file until a match has been found, 2664dc88ebeSGabor Kovesdanmaking searches potentially less expensive. 2674dc88ebeSGabor KovesdanPathnames are listed once per file searched. 2684dc88ebeSGabor KovesdanIf the standard input is searched, the string 2694dc88ebeSGabor Kovesdan.Dq (standard input) 2704dc88ebeSGabor Kovesdanis written. 2714dc88ebeSGabor Kovesdan.It Fl Fl mmap 2724dc88ebeSGabor KovesdanUse 2734dc88ebeSGabor Kovesdan.Xr mmap 2 2744dc88ebeSGabor Kovesdaninstead of 2754dc88ebeSGabor Kovesdan.Xr read 2 2764dc88ebeSGabor Kovesdanto read input, which can result in better performance under some 2774dc88ebeSGabor Kovesdancircumstances but can cause undefined behaiour. 2784dc88ebeSGabor Kovesdan.It Fl m Ar num, Fl Fl max-count Ns = Ns Ar num 2794dc88ebeSGabor KovesdanStop reading the file after 2804dc88ebeSGabor Kovesdan.Ar num 2814dc88ebeSGabor Kovesdanmatches. 2824dc88ebeSGabor Kovesdan.It Fl n , Fl Fl line-number 2834dc88ebeSGabor KovesdanEach output line is preceded by its relative line number in the file, 2844dc88ebeSGabor Kovesdanstarting at line 1. 2854dc88ebeSGabor KovesdanThe line number counter is reset for each file processed. 2864dc88ebeSGabor KovesdanThis option is ignored if 2874dc88ebeSGabor Kovesdan.Fl c , 2884dc88ebeSGabor Kovesdan.Fl L , 2894dc88ebeSGabor Kovesdan.Fl l , 2904dc88ebeSGabor Kovesdanor 2914dc88ebeSGabor Kovesdan.Fl q 2924dc88ebeSGabor Kovesdanis 2934dc88ebeSGabor Kovesdanspecified. 2944dc88ebeSGabor Kovesdan.It Fl Fl null 2954dc88ebeSGabor KovesdanPrints a zero-byte after the file name. 2964dc88ebeSGabor Kovesdan.It Fl O 2974dc88ebeSGabor KovesdanIf 2984dc88ebeSGabor Kovesdan.Fl R 2994dc88ebeSGabor Kovesdanis specified, follow symbolic links only if they were explicitly listed 3004dc88ebeSGabor Kovesdanon the command line. 3014dc88ebeSGabor KovesdanThe default is not to follow symbolic links. 3024dc88ebeSGabor Kovesdan.It Fl o, Fl Fl only-matching 3034dc88ebeSGabor KovesdanPrints only the matching part of the lines. 3044dc88ebeSGabor Kovesdan.It Fl p 3054dc88ebeSGabor KovesdanIf 3064dc88ebeSGabor Kovesdan.Fl R 3074dc88ebeSGabor Kovesdanis specified, no symbolic links are followed. 3084dc88ebeSGabor KovesdanThis is the default. 3094dc88ebeSGabor Kovesdan.It Fl q , Fl Fl quiet , Fl Fl silent 3104dc88ebeSGabor KovesdanQuiet mode: 3114dc88ebeSGabor Kovesdansuppress normal output. 3124dc88ebeSGabor Kovesdan.Nm grep 3134dc88ebeSGabor Kovesdanwill only search a file until a match has been found, 3144dc88ebeSGabor Kovesdanmaking searches potentially less expensive. 3154dc88ebeSGabor Kovesdan.It Fl R , Fl r , Fl Fl recursive 3164dc88ebeSGabor KovesdanRecursively search subdirectories listed. 3174dc88ebeSGabor Kovesdan.It Fl S 3184dc88ebeSGabor KovesdanIf 3194dc88ebeSGabor Kovesdan.Fl R 3204dc88ebeSGabor Kovesdanis specified, all symbolic links are followed. 3214dc88ebeSGabor KovesdanThe default is not to follow symbolic links. 3224dc88ebeSGabor Kovesdan.It Fl s , Fl Fl no-messages 3234dc88ebeSGabor KovesdanSilent mode. 3244dc88ebeSGabor KovesdanNonexistent and unreadable files are ignored 3254dc88ebeSGabor Kovesdan(i.e. their error messages are suppressed). 3264dc88ebeSGabor Kovesdan.It Fl U , Fl Fl binary 3274dc88ebeSGabor KovesdanSearch binary files, but do not attempt to print them. 3284dc88ebeSGabor Kovesdan.It Fl V , Fl Fl version 3294dc88ebeSGabor KovesdanDisplay version information and exit. 3304dc88ebeSGabor Kovesdan.It Fl v , Fl Fl invert-match 3314dc88ebeSGabor KovesdanSelected lines are those 3324dc88ebeSGabor Kovesdan.Em not 3334dc88ebeSGabor Kovesdanmatching any of the specified patterns. 3344dc88ebeSGabor Kovesdan.It Fl w , Fl Fl word-regexp 3354dc88ebeSGabor KovesdanThe expression is searched for as a word (as if surrounded by 3364dc88ebeSGabor Kovesdan.Sq [[:<:]] 3374dc88ebeSGabor Kovesdanand 3384dc88ebeSGabor Kovesdan.Sq [[:>:]] ; 3394dc88ebeSGabor Kovesdansee 3404dc88ebeSGabor Kovesdan.Xr re_format 7 ) . 3414dc88ebeSGabor Kovesdan.It Fl x , Fl Fl line-regexp 3424dc88ebeSGabor KovesdanOnly input lines selected against an entire fixed string or regular 3434dc88ebeSGabor Kovesdanexpression are considered to be matching lines. 3444dc88ebeSGabor Kovesdan.It Fl y 3454dc88ebeSGabor KovesdanEquivalent to 3464dc88ebeSGabor Kovesdan.Fl i . 3474dc88ebeSGabor KovesdanObsoleted. 3484dc88ebeSGabor Kovesdan.It Fl Z , Fl z , Fl Fl decompress 3494dc88ebeSGabor KovesdanForce 3504dc88ebeSGabor Kovesdan.Nm grep 3514dc88ebeSGabor Kovesdanto behave as 3524dc88ebeSGabor Kovesdan.Nm zgrep . 3534dc88ebeSGabor Kovesdan.It Fl Fl binary-files Ns = Ns Ar value 3544dc88ebeSGabor KovesdanControls searching and printing of binary files. 3554dc88ebeSGabor KovesdanOptions are 3564dc88ebeSGabor Kovesdan.Ar binary , 3574dc88ebeSGabor Kovesdanthe default: search binary files but do not print them; 3584dc88ebeSGabor Kovesdan.Ar without-match : 3594dc88ebeSGabor Kovesdando not search binary files; 3604dc88ebeSGabor Kovesdanand 3614dc88ebeSGabor Kovesdan.Ar text : 3624dc88ebeSGabor Kovesdantreat all files as text. 3634dc88ebeSGabor Kovesdan.Sm off 3644dc88ebeSGabor Kovesdan.It Fl Fl context Op = Ar num 3654dc88ebeSGabor Kovesdan.Sm on 3664dc88ebeSGabor KovesdanPrint 3674dc88ebeSGabor Kovesdan.Ar num 3684dc88ebeSGabor Kovesdanlines of leading and trailing context. 3694dc88ebeSGabor KovesdanThe default is 2. 3704dc88ebeSGabor Kovesdan.It Fl Fl line-buffered 3714dc88ebeSGabor KovesdanForce output to be line buffered. 3724dc88ebeSGabor KovesdanBy default, output is line buffered when standard output is a terminal 3734dc88ebeSGabor Kovesdanand block buffered otherwise. 3744dc88ebeSGabor Kovesdan.Pp 3754dc88ebeSGabor Kovesdan.El 3764dc88ebeSGabor KovesdanIf no file arguments are specified, the standard input is used. 377*e9a67923SGabor Kovesdan.Sh EXIT STATUS 3784dc88ebeSGabor KovesdanThe 3794dc88ebeSGabor Kovesdan.Nm grep 3804dc88ebeSGabor Kovesdanutility exits with one of the following values: 3814dc88ebeSGabor Kovesdan.Pp 3824dc88ebeSGabor Kovesdan.Bl -tag -width flag -compact 3834dc88ebeSGabor Kovesdan.It Li 0 3844dc88ebeSGabor KovesdanOne or more lines were selected. 3854dc88ebeSGabor Kovesdan.It Li 1 3864dc88ebeSGabor KovesdanNo lines were selected. 3874dc88ebeSGabor Kovesdan.It Li \*(Gt1 3884dc88ebeSGabor KovesdanAn error occurred. 3894dc88ebeSGabor Kovesdan.El 3904dc88ebeSGabor Kovesdan.Sh EXAMPLES 3914dc88ebeSGabor KovesdanTo find all occurrences of the word 3924dc88ebeSGabor Kovesdan.Sq patricia 3934dc88ebeSGabor Kovesdanin a file: 3944dc88ebeSGabor Kovesdan.Pp 3954dc88ebeSGabor Kovesdan.Dl $ grep 'patricia' myfile 3964dc88ebeSGabor Kovesdan.Pp 3974dc88ebeSGabor KovesdanTo find all occurrences of the pattern 3984dc88ebeSGabor Kovesdan.Ql .Pp 3994dc88ebeSGabor Kovesdanat the beginning of a line: 4004dc88ebeSGabor Kovesdan.Pp 4014dc88ebeSGabor Kovesdan.Dl $ grep '^\e.Pp' myfile 4024dc88ebeSGabor Kovesdan.Pp 4034dc88ebeSGabor KovesdanThe apostrophes ensure the entire expression is evaluated by 4044dc88ebeSGabor Kovesdan.Nm grep 4054dc88ebeSGabor Kovesdaninstead of by the user's shell. 4064dc88ebeSGabor KovesdanThe caret 4074dc88ebeSGabor Kovesdan.Ql ^ 4084dc88ebeSGabor Kovesdanmatches the null string at the beginning of a line, 4094dc88ebeSGabor Kovesdanand the 4104dc88ebeSGabor Kovesdan.Ql \e 4114dc88ebeSGabor Kovesdanescapes the 4124dc88ebeSGabor Kovesdan.Ql \&. , 4134dc88ebeSGabor Kovesdanwhich would otherwise match any character. 4144dc88ebeSGabor Kovesdan.Pp 4154dc88ebeSGabor KovesdanTo find all lines in a file which do not contain the words 4164dc88ebeSGabor Kovesdan.Sq foo 4174dc88ebeSGabor Kovesdanor 4184dc88ebeSGabor Kovesdan.Sq bar : 4194dc88ebeSGabor Kovesdan.Pp 4204dc88ebeSGabor Kovesdan.Dl $ grep -v -e 'foo' -e 'bar' myfile 4214dc88ebeSGabor Kovesdan.Pp 4224dc88ebeSGabor KovesdanA simple example of an extended regular expression: 4234dc88ebeSGabor Kovesdan.Pp 4244dc88ebeSGabor Kovesdan.Dl $ egrep '19|20|25' calendar 4254dc88ebeSGabor Kovesdan.Pp 4264dc88ebeSGabor KovesdanPeruses the file 4274dc88ebeSGabor Kovesdan.Sq calendar 4284dc88ebeSGabor Kovesdanlooking for either 19, 20, or 25. 4294dc88ebeSGabor Kovesdan.Sh SEE ALSO 4304dc88ebeSGabor Kovesdan.Xr ed 1 , 4314dc88ebeSGabor Kovesdan.Xr ex 1 , 4324dc88ebeSGabor Kovesdan.Xr gzip 1 , 4334dc88ebeSGabor Kovesdan.Xr sed 1 , 4344dc88ebeSGabor Kovesdan.Xr re_format 7 4354dc88ebeSGabor Kovesdan.Sh STANDARDS 4364dc88ebeSGabor KovesdanThe 4374dc88ebeSGabor Kovesdan.Nm 4384dc88ebeSGabor Kovesdanutility is compliant with the 4394dc88ebeSGabor Kovesdan.St -p1003.1-2008 4404dc88ebeSGabor Kovesdanspecification. 4414dc88ebeSGabor Kovesdan.Pp 4424dc88ebeSGabor KovesdanThe flags 4434dc88ebeSGabor Kovesdan.Op Fl AaBbCDdGHhIJLmoPRSUVwZ 4444dc88ebeSGabor Kovesdanare extensions to that specification, and the behaviour of the 4454dc88ebeSGabor Kovesdan.Fl f 4464dc88ebeSGabor Kovesdanflag when used with an empty pattern file is left undefined. 4474dc88ebeSGabor Kovesdan.Pp 4484dc88ebeSGabor KovesdanAll long options are provided for compatibility with 4494dc88ebeSGabor KovesdanGNU versions of this utility. 4504dc88ebeSGabor Kovesdan.Pp 4514dc88ebeSGabor KovesdanHistoric versions of the 4524dc88ebeSGabor Kovesdan.Nm grep 4534dc88ebeSGabor Kovesdanutility also supported the flags 4544dc88ebeSGabor Kovesdan.Op Fl ruy . 4554dc88ebeSGabor KovesdanThis implementation supports those options; 4564dc88ebeSGabor Kovesdanhowever, their use is strongly discouraged. 4574dc88ebeSGabor Kovesdan.Sh HISTORY 4584dc88ebeSGabor KovesdanThe 4594dc88ebeSGabor Kovesdan.Nm grep 4604dc88ebeSGabor Kovesdancommand first appeared in 4614dc88ebeSGabor Kovesdan.At v6 . 462