Annotation of 43BSDReno/usr.bin/grep/egrep/grep.1, revision 1.1

1.1     ! root        1: .\" Copyright (c) 1980, 1990 The Regents of the University of California.
        !             2: .\" All rights reserved.
        !             3: .\"
        !             4: .\" Redistribution and use in source and binary forms are permitted provided
        !             5: .\" that: (1) source distributions retain this entire copyright notice and
        !             6: .\" comment, and (2) distributions including binaries display the following
        !             7: .\" acknowledgement:  ``This product includes software developed by the
        !             8: .\" University of California, Berkeley and its contributors'' in the
        !             9: .\" documentation or other materials provided with the distribution and in
        !            10: .\" all advertising materials mentioning features or use of this software.
        !            11: .\" Neither the name of the University nor the names of its contributors may
        !            12: .\" be used to endorse or promote products derived from this software without
        !            13: .\" specific prior written permission.
        !            14: .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
        !            15: .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
        !            16: .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
        !            17: .\"
        !            18: .\"     @(#)grep.1     6.5 (Berkeley) 7/24/90
        !            19: .\"
        !            20: .Dd July 24, 1990
        !            21: .Dt GREP 1
        !            22: .Os BSD 4.4
        !            23: .Sh NAME
        !            24: .Nm grep
        !            25: .Nd File pattern searcher.
        !            26: .Sh SYNOPSIS
        !            27: .Nm grep
        !            28: .Op Fl bchilnosvw
        !            29: .Op Fl e Ar pattern
        !            30: .Ar
        !            31: .Nm egrep
        !            32: .Op Fl bchilnosv
        !            33: .Op Fl e Ar pattern
        !            34: .Op Fl f Ar pattern_file
        !            35: .Ar
        !            36: .Nm fgrep
        !            37: .Op Fl bchilnosvx
        !            38: .Op Fl e Ar pattern
        !            39: .Op Fl f Ar pattern_file
        !            40: .Ar
        !            41: .Sh DESCRIPTION
        !            42: The
        !            43: .Nm grep
        !            44: utilities search the given input files selecting lines
        !            45: which match one or more patterns; the type of patterns is controlled
        !            46: by the options specified.
        !            47: By default, a pattern
        !            48: matches an input line if any regular expression (RE) in the
        !            49: pattern matches the input line without its trailing <new-line>.
        !            50: A null RE matches every line.
        !            51: Each input line that matches at
        !            52: least one of the patterns is written to the standard output.
        !            53: .Pp
        !            54: For simple patterns or
        !            55: .Xr ex 1
        !            56: or
        !            57: .Xr ed 1
        !            58: style regular expressions, the
        !            59: .Nm grep
        !            60: utility is used.
        !            61: The
        !            62: .Nm egrep
        !            63: utility
        !            64: can handle extended regular expressions and
        !            65: embedded <newline>s in pattern
        !            66: .Nm Fgrep
        !            67: is quick but is designed to handle fixed strings.
        !            68: A fixed string
        !            69: is a string of characters,
        !            70: each character
        !            71: is matched only by itself.
        !            72: The pattern
        !            73: value can consist of multiple lines with
        !            74: embedded <newline>s.
        !            75: In this case, the <newline>s
        !            76: act as alternation characters, allowing any of the
        !            77: pattern lines to match a portion of the input.
        !            78: .Pp
        !            79: The following options are available:
        !            80: .Pp
        !            81: .Tw Fl
        !            82: .Tp Fl b
        !            83: The block number on the disk in which a matched pattern is located
        !            84: is displayed in front of the respective matched line.
        !            85: .Tp Fl c
        !            86: Only a count of selected lines is written to standard
        !            87: output.
        !            88: .Tc Fl e
        !            89: .Ws
        !            90: .Ar expression
        !            91: .Cx
        !            92: Specify a pattern used during the search of the
        !            93: input.
        !            94: Multiple
        !            95: .Fl e
        !            96: options can be used to specify
        !            97: multiple patterns; an input line is selected of it
        !            98: matches any of the specified patterns.
        !            99: .Tc Fl f
        !           100: .Ws
        !           101: .Ar pattern_file
        !           102: .Cx
        !           103: The pattern is read from the file named by the
        !           104: pathname pattern_file.
        !           105: Trailing newlines
        !           106: in the pattern_file are ignored.
        !           107: .Pf \&( Nm egrep
        !           108: and
        !           109: .Nm fgrep
        !           110: only).
        !           111: .Tp Fl h
        !           112: Never print filename headers with output lines.
        !           113: .Tp Fl i
        !           114: The case of letters is ignored in making comparisons \- that is, upper and
        !           115: lower case are considered identical.
        !           116: .Tp Fl l
        !           117: Only the names of files containing selected lines
        !           118: are written to standard output.
        !           119: Pathnames are
        !           120: listed once per file searched.
        !           121: If the standard
        !           122: input is searched, the pathname
        !           123: .Sq Fl
        !           124: is written.
        !           125: .Tp Fl n
        !           126: Each output line is preceded by its relative line
        !           127: number in the file; each file starting at line 1.
        !           128: The line number counter is reset for each file processed.
        !           129: This option is ignored if
        !           130: .Fl c ,
        !           131: .Fl l ,
        !           132: or
        !           133: .Fl s
        !           134: is
        !           135: specified.
        !           136: .Tp Fl o
        !           137: Always print filename headers with output lines.
        !           138: .Tp Fl s
        !           139: Silent mode.  Nothing is printed (except error messages).
        !           140: This is useful for checking the error status.
        !           141: .Tp Fl v
        !           142: Selected lines are those
        !           143: .Em not
        !           144: matching the specified
        !           145: patterns.
        !           146: .Tp Fl x
        !           147: Only input lines selected against an entire fixed
        !           148: string or regular expression are considered to be
        !           149: matching lines.
        !           150: .Pf \&( Nm fgrep
        !           151: only).
        !           152: .Tp Fl w
        !           153: The expression is searched for as a word
        !           154: (as if surrounded by `\e<' and `\e>', see
        !           155: .Xr ex  1  . )
        !           156: .Pf \&( Nm grep
        !           157: only)
        !           158: .Pp
        !           159: .Tp
        !           160: If no file arguments are specified, the
        !           161: standard input is used.
        !           162: .Pp
        !           163: The
        !           164: .Nm grep
        !           165: utility exits with one of the following values:
        !           166: .Dw Ds
        !           167: .Dp Li \&0
        !           168: One or more lines were selected.
        !           169: .Dp Li \&1
        !           170: No lines were selected.
        !           171: .Dp Li \&>1
        !           172: An error occurred.
        !           173: .Dp
        !           174: .Sh EXTENDED REGULAR EXPRESSIONS
        !           175: The following characters are interpreted by
        !           176: .Nm egrep :
        !           177: .Tw Ds
        !           178: .Tp Cm \&$
        !           179: Align the match from the end of the line.
        !           180: .Tp Cm \&^
        !           181: Align the match from the beginning of the line.
        !           182: .Tp Cm \&|
        !           183: Add another pattern (see example below).
        !           184: .Tp Cm \&?
        !           185: Match 1 or less sequential repetitions of the pattern.
        !           186: .Tp Cm \&+
        !           187: Match 1 or more sequential repetitions of the pattern.
        !           188: .Tp Cm \&*
        !           189: Match 0 or more sequential repetitions of the pattern.
        !           190: .Tp Cm \&[]
        !           191: Match any single character or range of characters
        !           192: enclosed in the brackets.
        !           193: .Tp Cm \&\e
        !           194: Escape special characters which have meaning to
        !           195: .Nm egrep ,
        !           196: the set of {$,.,^,[,],|,?,+,*,(,)}.
        !           197: .Tp
        !           198: .Sh EXAMPLES
        !           199: To find all occurances of the word patricia in a file:
        !           200: .Pp
        !           201: .Dl grep patricia myfile
        !           202: .Pp
        !           203: To find all occurences to the pattern
        !           204: .Sq Li \&.Pp
        !           205: at the beginning of a line:
        !           206: .Pp
        !           207: .Dl grep '^\e.Pp'
        !           208: .Pp
        !           209: The apostrophys assure the entire expression is evaluated by
        !           210: .Nm grep
        !           211: instead of by the
        !           212: users shell.
        !           213: The carat or hat
        !           214: .Sq Li \&^
        !           215: means
        !           216: .Em from the beginning of a line ,
        !           217: and the
        !           218: .Sq Li \&\e
        !           219: escapes the
        !           220: .Sq Li \&.
        !           221: which would otherwise match any character.
        !           222: .Pp
        !           223: A simple example of an extended regular expression:
        !           224: .Pp
        !           225: .Dl egrep '19|20|25' calendar
        !           226: .Pp
        !           227: Peruses the file calendar looking for either 19, 20
        !           228: or 25.
        !           229: .Sh SEE ALSO
        !           230: .Xr ed 1 ,
        !           231: .Xr ex 1 ,
        !           232: .Xr sed 1
        !           233: .Sh HISTORY
        !           234: .Nm Grep
        !           235: appeared in Version 6 AT&T Unix.
        !           236: .Sh BUGS
        !           237: Lines are limited to 256 characters; longer lines are truncated.

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.