0

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.

3
  • 2
    There probably aren't any line breaks (\n) until the end of the paragraph...
    – jasonwryan
    Commented Dec 7, 2012 at 1:52
  • @jasonwryan How could I know looking at a file a line break exist or not?
    – user3539
    Commented Dec 7, 2012 at 1:55
  • 1
    Open it in a text editor and disable word wrapping
    – Karthik T
    Commented Dec 7, 2012 at 2:15

1 Answer 1

0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .