Unix/Linux Go Back    


Solaris The Solaris Operating System, usually known simply as Solaris, is a Unix-based operating system introduced by Sun Microsystems. The Solaris OS is now owned by Oracle.

delete first 100 lines from a file

Solaris


Tags
sed, tail

Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 11-15-2007
salaathi's Unix or Linux Image
salaathi salaathi is offline
Registered User
 
Join Date: Sep 2007
Last Activity: 31 December 2010, 9:01 AM EST
Location: Madurai
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Unix or Linux Question delete first 100 lines from a file

I have a file with 28,00,000 lines of rows in this the first 80 lines will be chunks .

I want to delete the chunks of 80 lines. I tried tail -f2799920 filename.
is there any efficient way to do this.

Thanks in advance.
Sponsored Links
    #2  
Old Unix and Linux 11-15-2007
Yogesh Sawant's Unix or Linux Image
Yogesh Sawant Yogesh Sawant is offline Forum Advisor  
Full Time Dad
 
Join Date: Sep 2006
Last Activity: 19 July 2017, 7:13 AM EDT
Location: Rossem, Tazenda
Posts: 1,213
Thanks: 7
Thanked 18 Times in 17 Posts

Code:
sed '1,100d' filename > newfile

sed would be faster than tail in my opinion
Sponsored Links
    #3  
Old Unix and Linux 11-15-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
 
Join Date: Mar 2005
Last Activity: 10 January 2017, 8:10 AM EST
Location: classification algos
Posts: 3,215
Thanks: 19
Thanked 31 Times in 28 Posts
if -i option is available in sed ( GNU sed )

use it for in-place modification


Code:
sed -i '1,100d' filename

    #4  
Old Unix and Linux 11-15-2007
salaathi's Unix or Linux Image
salaathi salaathi is offline
Registered User
 
Join Date: Sep 2007
Last Activity: 31 December 2010, 9:01 AM EST
Location: Madurai
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
MySQL

Yes. Its really faster than the tail command.

Thanks Yogesh


Sarathi
Sponsored Links
    #5  
Old Unix and Linux 06-09-2009
libin4u2000 libin4u2000 is offline
Registered User
 
Join Date: Dec 2008
Last Activity: 30 November 2009, 9:55 PM EST
Location: Singapore
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
delete liines using sed.

Hi,

I am trying to delete all lines in a file which starts with SG.

Command : sed -e "s/^SG/d/" bcpfile > test1.

But the above command just replaces 'SG' with 'd'. Please suggest the correct command to delete the whole line.

Thanks.
David.
Sponsored Links
    #6  
Old Unix and Linux 06-09-2009
a2156z
Guest
 
Posts: n/a
sed -e "s/^SG//d"
Sponsored Links
    #7  
Old Unix and Linux 06-09-2009
Franklin52's Unix or Linux Image
Franklin52 Franklin52 is offline Forum Staff  
Moderator
 
Join Date: Feb 2007
Last Activity: 5 May 2017, 7:24 AM EDT
Location: The Netherlands
Posts: 7,746
Thanks: 139
Thanked 558 Times in 520 Posts
Quote:
Originally Posted by a2156z View Post
sed -e "s/^SG//d"
Should be:


Code:
sed "/^SG/d" file

Regards
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
In a huge file, Delete duplicate lines leaving unique lines krishnix UNIX for Advanced & Expert Users 16 08-04-2011 04:47 AM
Delete some lines in a file ponmuthu UNIX for Advanced & Expert Users 5 07-28-2010 02:39 PM
How get only required lines & delete the rest of the lines in file reva UNIX for Dummies Questions & Answers 7 06-01-2010 02:58 AM
How to delete lines in a file that have duplicates or derive the lines that aper once necroman08 Shell Programming and Scripting 3 07-17-2009 05:07 AM
delete the lines from file sameersam Shell Programming and Scripting 2 04-04-2006 01:32 AM



All times are GMT -4. The time now is 06:56 AM.