Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

cgrep(1) [minix man page]

CGREP(1)						      General Commands Manual							  CGREP(1)

NAME
cgrep - grep and display context SYNOPSIS
cgrep [-a n] [-b n] [-f] [-l n] [-n] [-w n] pattern [file] ... OPTIONS
-a How many lines to display after the matching line -b How many lines to display before the matching line -f Suppress file name in the output -l Lines are truncated to this length before comparison -n Suppress line numbers in the output -w Sets window size (same as -a n -b n) EXAMPLES
cgrep -w 3 hello file1 # Print 3 lines of context each way DESCRIPTION
Cgrep is a program like grep, except that it also can print a few lines above and/or below the matching lines. It also prints the line numbers of the output. SEE ALSO
grep(1), fgrep(1). CGREP(1)

Check Out this Related Man Page

GREP(1) 						      General Commands Manual							   GREP(1)

NAME
grep, g - search a file for a pattern SYNOPSIS
grep [ option ... ] pattern [ file ... ] g [ option ... ] pattern [ file ... ] DESCRIPTION
Grep searches the input files (standard input default) for lines that match the pattern, a regular expression as defined in regexp(7) with the addition of a newline character as an alternative (substitute for |) with lowest precedence. Normally, each line matching the pattern is `selected', and each selected line is copied to the standard output. The options are -c Print only a count of matching lines. -h Do not print file name tags (headers) with output lines. -e The following argument is taken as a pattern. This option makes it easy to specify patterns that might confuse argument parsing, such as -n. -i Ignore alphabetic case distinctions. The implementation folds into lower case all letters in the pattern and input before interpre- tation. Matched lines are printed in their original form. -l (ell) Print the names of files with selected lines; don't print the lines. -L Print the names of files with no selected lines; the converse of -l. -n Mark each printed line with its line number counted in its file. -s Produce no output, but return status. -v Reverse: print lines that do not match the pattern. -f The pattern argument is the name of a file containing regular expressions one per line. -b Don't buffer the output: write each output line as soon as it is discovered. Output lines are tagged by file name when there is more than one input file. (To force this tagging, include /dev/null as a file name argument.) Care should be taken when using the shell metacharacters $*[^|()= and newline in pattern; it is safest to enclose the entire expression in single quotes '...'. An expression starting with '*' will treat the rest of the expression as literal characters. G invokes grep with -n and forces tagging of output lines by file name. If no files are listed, it searches all files matching *.C *.b *.c *.h *.m *.cc *.java *.cgi *.pl *.py *.tex *.ms SOURCE
/src/cmd/grep /bin/g SEE ALSO
ed(1), awk(1), sed(1), sam(1), regexp(7) DIAGNOSTICS
Exit status is null if any lines are selected, or non-null when no lines are selected or an error occurs. GREP(1)
Man Page

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

cgrep for the most recent 15min output

I have a history file that recieves all sorts of messages 24 hours a day. I have a script that retreives various messages in the history file. There is an one multi line output that is sent to the history file that comes in every 15 minutes. How do I cgrep for the most recent 15 minute output in... (5 Replies)
Discussion started by: jojojmac5
5 Replies

2. UNIX for Dummies Questions & Answers

grep, cgrep or something close

Hi, New to this forum. Nice forum and very helpful. Quick question. I'm trying to grep a list of numbers from single digit to 3-digit. For example, I have a pool of numbers that contain two specific numbers, 17 and 177. I would like to grep for 17 but not get 177. When using grep, I also... (4 Replies)
Discussion started by: dejit
4 Replies

3. Shell Programming and Scripting

print chunk of lines only if there is a pattern match in between them

Hi All, Please find the sample file below: NAME ID NUMBER -------------------------------------------------------------------------------------------------- --------- abcdefgheija;lksdf ... (13 Replies)
Discussion started by: niel.verty
13 Replies

4. UNIX for Advanced & Expert Users

grep across multiple lines

How do you grep 'select * from table_name' string from a script if the select * and from table_name are on 2 different lines ? like select * from table_name Any help would be greatly appreciated !!! Thanks RDR (4 Replies)
Discussion started by: RDR
4 Replies

5. Shell Programming and Scripting

sed Range Pattern and 2 lines before Start Pattern

Hi all, I have been searching all over Google but I am unable to find a solution for a particular result that I am trying to achieve. Consider the following input: 1 2 3 4 5 B4Srt1--Variable-0000 B4Srt2--Variable-1111 Srt 6 7 8 9 10 End (3 Replies)
Discussion started by: y2jacky
3 Replies