![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| delete n last lines of a file | ncatdesigner | Shell Programming and Scripting | 7 | 05-17-2008 07:07 AM |
| delete first 100 lines from a file | salaathi | SUN Solaris | 3 | 11-15-2007 12:01 AM |
| delete first 100 lines rather than zero out of file | thepurple | SUN Solaris | 7 | 11-14-2007 09:35 AM |
| delete the lines from file | sameersam | Shell Programming and Scripting | 2 | 04-03-2006 10:32 PM |
| delete all lines in file | strok | UNIX for Dummies Questions & Answers | 6 | 03-11-2002 06:27 PM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Delete lines in a file
I wish to delete lines from a log file. Should take a date string as a variable. Find the date in the file, get the line number for the string. Delete lines from 1 to that (line number - 1), all from within a shell script. Is that possible ?.
Thnks, |
| Forum Sponsor | ||
|
|
|
|||
|
I tried this out , sed "1,${line} d" log_filename
This leaves the log_filename as it is. I would have to sed "1,${line} d" log_filename > log_filename.new mv log_filename log_filename.old mv log_filename.new log_filename the log file is constantly being written to, so how can I guarantee there wont be any loss of data... I wish to delete lines from the log as with "vi". Besides wont inodes change ? |