The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
prom in deleting a pattern suvendu4urs Shell Programming and Scripting 18 04-10-2008 06:36 AM
deleting lines using awk-best way? satnamx Shell Programming and Scripting 3 08-29-2007 07:24 PM
Search file for pattern and grab some lines before pattern frustrated1 Shell Programming and Scripting 2 12-22-2005 03:41 PM
deleting lines ajnabi Shell Programming and Scripting 8 05-02-2003 11:50 AM
deleting lines supercbw High Level Programming 1 05-06-2002 12:53 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-13-2008
larne larne is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 11
deleting lines after pattern using sed

I have seen there are many sed posts but still it is quite difficult to apply other post to my own problem

How can I delete all lines in a file from 2 lines after this pattern
Code:
*End_fine_coreg:_NORMAL
to the end of file?

Cheers
  #2 (permalink)  
Old 10-13-2008
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,310

Adjust num according to the number of lines you want printed after the line in question:

Code:
num=2
awk -v num=$num '/*End_fine_coreg:_NORMAL/ { n = 1 }
  NR - n > num { exit }
   {print}' "$FILE"
  #3 (permalink)  
Old 10-13-2008
RahulJoshi's Avatar
RahulJoshi RahulJoshi is offline
Registered User
  
 

Join Date: Aug 2008
Location: PUNE
Posts: 98
use this code:

csplit file1 /*End_fine_coreg:_NORMAL/+3

it will create two file named x00 x01 then u get ur desire result in x00 file.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 01:33 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0