Welcome, Guest
Username Password: Remember me
  • Page:
  • 1

TOPIC: Unix command

Unix command 9 months ago #715

  • vijayaha
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
  • Points: 22
  • Karma: 0
Hi All,

What is the command to find error line in a file and 10 lines above abd 10 lines below error line?

Say if I have a error text at line 35, I want 10 lines above 35th line and below 10 lines below 35th line.

Re: Unix command 8 months ago #720

  • rajeshkumar
  • OFFLINE
  • Moderator
  • I love software configuration management
  • Posts: 370
  • Points: 44551
  • Karma: 4
  • Honor Medal 2009
Hi Vijaya,

There are various ways to find this.. I opt to use following commands...

sed -n '25,45p' filename


> this will print lines number 25 to 45.

if multiple groups of lines then,

sed -n '25,45p 50,70p' filename
Regards,
Rajesh Kumar
Build and Release Engineer
My Blog: community.scmgalaxy.com/pg/profile/rajeshkumar
  • Page:
  • 1
Time to create page: 1.08 seconds

     
    
Home Forum