To remove some lines from a file
Sebastian Busch
sebastian_busch at gmx.net
Thu Oct 26 05:08:56 EDT 2006
Chetan wrote:
> Sebastian Busch <sebastian_busch at gmx.net> writes:
>
>> Steve Holden wrote:
>>> Sebastian Busch wrote:
>>>> umut.tabak at student.kuleuven.be wrote:
>>>>> ... I would like to remove two lines from a file. ...
>>>> ... grep -v ...
>>> ... show ...
>> grep -v "`grep -v "commentsymbol" yourfile | head -2`" yourfile
>> ...
> I don't have the original post to know exactly what is needed, but looks like
> something that can be done by a single sed script.
>
> -Chetan
Hey!
The task is:
"Remove the first two lines that don't begin with "@" from a file."
Actually, the grep-thing I offered will also delete copies of these two
lines that occur in another place. That should be no problem if the file
is something like
@comment
deleteme
deleteme
@comment
data: x-y-dy
However, if this is not the case, it cannot be done this way.
How would you do it with sed?
Best,
Sebastian.
More information about the Python-list
mailing list