Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The grep manual says "By default, grep prints the matching lines.". What does this matching lines says. When I tried its prints the whole paragraph containing the pattern.

share|improve this question
There probably aren't any line breaks (\n) until the end of the paragraph... – jasonwryan Dec 7 '12 at 1:52
@jasonwryan How could I know looking at a file a line break exist or not? – user3539 Dec 7 '12 at 1:55
Open it in a text editor and disable word wrapping – Karthik T Dec 7 '12 at 2:15
up vote 0 down vote accepted

if you are using vi, and you are on the line you are looking for, moving one line down using your cursor keys, if you are jumping too much, it means that your paragraph contains more than one line on the terminal.

grep -n . filename

will show you all the lines preceded by a line number and colon sign (:) so you can differentiate between lines in the sense of text editor vs lines in the sense of screen real estate.

for grep, a line is delimited by a new line character, not by 80 characters that you see on a standard terminal window.

if you are running a putty terminal or any other xterm (as in gnome's terminal), stretch your terminal size to a larger one and you will see the lines realign themselves.

Hope this helps you to understand.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.