|
|
1.1 ! root 1: .TH GRE 1 ! 2: .CT 1 files ! 3: .SH NAME ! 4: gre, grep, egrep, fgrep \(mi search a file for a pattern ! 5: .SH SYNOPSIS ! 6: .B gre ! 7: [ ! 8: .I option ... ! 9: ] ! 10: .I pattern ! 11: [ ! 12: .I file ... ! 13: ] ! 14: .PP ! 15: .B grep ! 16: [ ! 17: .I option ... ! 18: ] ! 19: .I pattern ! 20: [ ! 21: .I file ... ! 22: ] ! 23: .PP ! 24: .B egrep ! 25: [ ! 26: .I option ... ! 27: ] ! 28: .I pattern ! 29: [ ! 30: .I file ... ! 31: ] ! 32: .PP ! 33: .B fgrep ! 34: [ ! 35: .I option ... ! 36: ] ! 37: .I strings ! 38: [ ! 39: .I file ... ! 40: ] ! 41: .SH DESCRIPTION ! 42: .I Gre\^ ! 43: searches the input ! 44: .I files\^ ! 45: (standard input default) ! 46: for lines (with newlines excluded) that match the ! 47: .I pattern, ! 48: a regular expression as defined in ! 49: .IR re (3). ! 50: A file name of ! 51: .B - ! 52: is interpreted as standard input. ! 53: Normally, each line matching the pattern is `selected', ! 54: and each selected line is copied to the standard output. ! 55: The options are ! 56: .TP ! 57: .B -1 ! 58: Print only the first selected line of each file argument. ! 59: .PD 0 ! 60: .TP ! 61: .B -b ! 62: Mark each printed line with its byte position in its file. ! 63: This is sometimes useful in locating patterns in non-text files. ! 64: .TP ! 65: .B -c ! 66: Print only a count of matching lines. ! 67: .TP ! 68: .BI -e " pattern" ! 69: Same as a simple ! 70: .I pattern ! 71: argument, ! 72: but useful when ! 73: .I pattern ! 74: begins with a ! 75: .BR - . ! 76: .TP ! 77: .B -E ! 78: Simulate ! 79: .IR egrep. ! 80: .TP ! 81: .BI -f " file" ! 82: Read the pattern from ! 83: .IR file ; ! 84: there is no ! 85: .I pattern ! 86: argument ! 87: .TP ! 88: .B -F ! 89: Simulate ! 90: .IR fgrep. ! 91: .TP ! 92: .B -G ! 93: Simulate ! 94: .IR grep. ! 95: .TP ! 96: .B -h ! 97: Do not print filename tags (headers) with output lines. ! 98: .TP ! 99: .B -i ! 100: Ignore alphabetic case distinctions. ! 101: .TP ! 102: .B -l ! 103: Print the names of files with selected lines; don't print the lines. ! 104: .TP ! 105: .B -L ! 106: Print the names of files with no selected lines; ! 107: the converse of ! 108: .BR -l . ! 109: .TP ! 110: .B -n ! 111: Mark each printed line with its line number counted in its file. ! 112: .TP ! 113: .B -s ! 114: Produce no output, but return status. ! 115: .TP ! 116: .B -v ! 117: Reverse: print lines that do not match the pattern. ! 118: .TP ! 119: .B -x ! 120: Exact match: The pattern is ! 121: .BI ^( pattern )$ . ! 122: .PD ! 123: .PP ! 124: Output lines are tagged by filename when there is more than one ! 125: input file. ! 126: (To force this tagging, include ! 127: .B /dev/null ! 128: as a filename argument.) ! 129: If the output line exceeds some internal limit, ! 130: a warning is given and a small block of text surrounding the match is printed. ! 131: .PP ! 132: Care should be taken when ! 133: using the shell metacharacters ! 134: .B $*[^|()\e ! 135: and newline ! 136: in ! 137: .IR pattern ; ! 138: it is safest to enclose the ! 139: entire expression ! 140: in single quotes ! 141: .BR \&\|\(fm \|.\|.\|.\| \(fm . ! 142: .PP ! 143: .I Gre ! 144: supplants three classic programs, which are still available: ! 145: .PP ! 146: .I Grep ! 147: handles only ! 148: .IR ed (1)-like ! 149: regular expressions. ! 150: It uses ! 151: .L \e(\|\e) ! 152: instead of ! 153: .LR (\|) . ! 154: .PP ! 155: .I Egrep ! 156: handles the same patterns as ! 157: .I gre ! 158: except for back-referencing with ! 159: .BR \e1 , ! 160: .BR \e2 , ! 161: \&... ! 162: .PP ! 163: .I Fgrep ! 164: handles no operators except newline (alternation). ! 165: .SH SEE ALSO ! 166: .IR re (3), ! 167: .IR awk (1), ! 168: .IR sed (1), ! 169: .IR sam (9.1), ! 170: .IR strings (1) ! 171: .SH DIAGNOSTICS ! 172: Exit status is 0 if any lines are selected, ! 173: 1 if none, 2 for syntax errors, inaccessible files ! 174: (even if matches were found). ! 175: Warnings will be given for input lines that exceed ! 176: a (generous) internal limit. ! 177: .SH BUGS ! 178: .I Grep, egrep, ! 179: and ! 180: .I fgrep ! 181: do not support some options and print block numbers ! 182: rather than byte numbers for option ! 183: .BR -b .
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.