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 > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Deleting lines in text file hern14 UNIX for Dummies Questions & Answers 5 05-16-2008 03:03 PM
Deleting lines in a file reachsamir Shell Programming and Scripting 2 05-29-2007 11:17 AM
Deleting last 2 lines from the file. videsh77 Shell Programming and Scripting 4 04-06-2007 01:14 PM
Deleting Lines from .csv file 009satya Shell Programming and Scripting 3 11-14-2006 03:41 AM
deleting lines in a log file BG_JrAdmin Shell Programming and Scripting 2 08-22-2006 11:12 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #8 (permalink)  
Old 09-21-2005
Nirgude07 Nirgude07 is offline
Registered User
  
 

Join Date: Sep 2005
Posts: 5
No I am running this under sh . I will try this out with ksh..thanks for your help...still suggest me the better way to do this if you think any...truly thanks in advance.
  #9 (permalink)  
Old 09-21-2005
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,190
Code:
perl -pi -e '$_ = "" if ($. >= <start> && $. <= <end> );'
Where <start> is the first line you want to delete and <end> is the last line you want to delete.

eg:
Code:
perl -pi -e '$_ = "" if ($. >= 2 && $. <= 4 );' file
deletes lines 2 to 4.
  #10 (permalink)  
Old 09-21-2005
Nirgude07 Nirgude07 is offline
Registered User
  
 

Join Date: Sep 2005
Posts: 5
Smile

Thank you very much reborg. I wonder if we can do this by using awk...I don't know really.
  #11 (permalink)  
Old 09-21-2005
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,190
Yes, but not if you have very long lines, or without opening a nother file. Also perl will be MUCH faster.
  #12 (permalink)  
Old 07-01-2009
rakesh_pagadala rakesh_pagadala is offline
Registered User
  
 

Join Date: May 2009
Location: hyderabad
Posts: 20
we can also delete records using
sed 'n,xd' inputfile > outputfile
where n would starting range x would be ending range
Sponsored Links
Reply

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 05:02 AM.


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