How to grep from line n1 to line n2 in a file?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anil cha
    New Member
    • Mar 2011
    • 1

    How to grep from line n1 to line n2 in a file?

    I have to grep a file from line n1 and n2. Is there a single command unix to do that?
  • jjdot
    New Member
    • Feb 2011
    • 11

    #2
    awk '{ if (n1 <= NR && NR <= n2) print NR $0; }' yourfile | grep expression

    Comment

    Working...