delete first 100 lines from a file


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
Operating Systems Solaris delete first 100 lines from a file
# 1  
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.
# 2  
Code:
sed '1,100d' filename > newfile

sed would be faster than tail in my opinion
# 3  
if -i option is available in sed ( GNU sed )

use it for in-place modification

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

# 4  
MySQL

Yes. Its really faster than the tail command.

Thanks Yogesh


Sarathi
# 5  
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.
# 6  
sed -e "s/^SG//d"
a2156z
# 7  
Quote:
Originally Posted by a2156z
sed -e "s/^SG//d"
Should be:

Code:
sed "/^SG/d" file

Regards
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #353
Difficulty: Medium
mawk is a very fast AWK implementation by Mike Brennan based on a Python interpreter.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Delete 40 lines after every 24 lines from a file

Hello, I have file of more than 10000 lines. I want to delete 40 lines after every 20 lines. e.g from a huge file, i want to delete line no from 34 - 74, then 94 - 134 etc and so on. Please let me know how i can do it. Best regards, (11 Replies)
Discussion started by: nehashine
11 Replies

2. UNIX for Advanced & Expert Users

Delete first 100 lines from a BIG File

Hi, I need a unix command to delete first n (say 100) lines from a log file. I need to delete some lines from the file without using any temporary file. I found sed -i is an useful command for this but its not supported in my environment( AIX 6.1 ). File size is approx 100MB. Thanks in... (18 Replies)
Discussion started by: unohu
18 Replies

3. UNIX for Advanced & Expert Users

In a huge file, Delete duplicate lines leaving unique lines

Hi All, I have a very huge file (4GB) which has duplicate lines. I want to delete duplicate lines leaving unique lines. Sort, uniq, awk '!x++' are not working as its running out of buffer space. I dont know if this works : I want to read each line of the File in a For Loop, and want to... (16 Replies)
Discussion started by: krishnix
16 Replies

4. UNIX for Advanced & Expert Users

Delete some lines in a file

hi i need to delete 3 lines (last 3 lines ) in a file for ex : >cat file 1 2 3 4 5 abc def ghi i hav to delete last 3 line in above file please help me (5 Replies)
Discussion started by: ponmuthu
5 Replies

5. UNIX for Dummies Questions & Answers

How get only required lines & delete the rest of the lines in file

Hiiii I have a file which contains huge data as a.dat: PDE 1990 1 9 18 51 28.90 24.7500 95.2800 118.0 6.1 0.0 BURMA event name: 010990D time shift: 7.3000 half duration: 5.0000 latitude: 24.4200 longitude: 94.9500 depth: 129.6000 Mrr: ... (7 Replies)
Discussion started by: reva
7 Replies

6. Shell Programming and Scripting

How to delete lines in a file that have duplicates or derive the lines that aper once

Input: a b b c d d I need: a c I know how to get this (the lines that have duplicates) : b d sort file | uniq -d But i need opossite of this. I have searched the forum and other places as well, but have found solution for everything except this variant of the problem. (3 Replies)
Discussion started by: necroman08
3 Replies

7. Solaris

delete first 100 lines rather than zero out of file

Hi experts, in my solaris 9 the file- /var/adm/messeages growin too first. by 24 hours 40MB. And always giving the below messages-- bash-2.05# tail -f messages Nov 9 16:35:38 ME1 last message repeated 1 time Nov 9 16:35:38 ME1 ftpd: wtmpx /var/adm/wtmpx No such file or directory Nov 9... (7 Replies)
Discussion started by: thepurple
7 Replies

8. UNIX for Dummies Questions & Answers

delete lines in a file

I've got a file like this: Grid-ref= 443, 229 167 169 204 233 290 309 308 326 300 251 194 161 148 189 228 251 296 329 331 338 308 263 219 179 178 203 215 252 277 319 327 335 312 264 196 149 120 172 226 253 297 329 323 322 305 242 203 136 ... (20 Replies)
Discussion started by: su_in99
20 Replies

9. Shell Programming and Scripting

delete the lines from file

i have two files & want to delete the lines from 2nd file which matches with 1st file (2 Replies)
Discussion started by: sameersam
2 Replies

10. UNIX for Dummies Questions & Answers

delete all lines in file

how can i delete all lines in file by using "vi" ? (6 Replies)
Discussion started by: strok
6 Replies