![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Deleting lines in text file | hern14 | UNIX for Dummies Questions & Answers | 5 | 05-16-2008 12:03 PM |
| Deleting lines in a file | reachsamir | Shell Programming and Scripting | 2 | 05-29-2007 08:17 AM |
| Deleting last 2 lines from the file. | videsh77 | Shell Programming and Scripting | 4 | 04-06-2007 10:14 AM |
| Deleting Lines from .csv file | 009satya | Shell Programming and Scripting | 3 | 11-14-2006 12:41 AM |
| deleting lines in a log file | BG_JrAdmin | Shell Programming and Scripting | 2 | 08-22-2006 08:12 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
How I can delete 100 lines anywhere in a file without opening a file and without renaming the file.
|
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
I could think of this:
Code:
sed -n "${to},${from}p" file_to_cut_lines_from | cat > file_to_cut_lines_from
This works in ksh, but is not portable in sh and bash. This has to do with the way ksh treats the '>'. There is a post where Perderabo has given an explaination for this - but I cant seem to remember where that post is... Last edited by blowtorch; 09-21-2005 at 09:58 AM. |
|
#3
|
|||
|
|||
|
Actually I have 8GB file which contains 200,000 records and I want to delete first 50,000 records without opening the file. At the same time I don't want to create another file once I delete the records because of space problem on server.
Is there any way I can delete 50,000 lines from 'abc.dat' and redirect output in the 'abc.dat' only. |
|
#4
|
|||
|
|||
|
ed can do this but it does create a temp file.
|
|
#5
|
||||
|
||||
|
Records are potentially very different from lines. You could have your own delimiters and have a record spanning several lines. If each line is a single record, then you could still run the following command under ksh:
Code:
sed -n "50000,200000p" file_to_cut_lines_from | cat > file_to_cut_lines_from |
|
#6
|
|||
|
|||
|
It's not working....it's deleting the whole file..
|
|
#7
|
||||
|
||||
|
Are you running this under ksh? It will *only* work under ksh and *not* under bash and sh.
|
||||
| Google The UNIX and Linux Forums |