Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
2  
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
1  
Open it in a text editor and disable word wrapping –  Karthik T Dec 7 '12 at 2:15

1 Answer 1

up vote 0 down vote accepted

if you are using vi, and you are on the line you are looking for, moving onle 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 column sigh (:) 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 understand.

share|improve this answer

Your Answer

 
discard

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.