Sebastian Busch <[EMAIL PROTECTED]> writes:
>The task is:
>
>"Remove the first two lines that don't begin with "@" from a file."
>
>How would you do it with sed?
Why a sed solution in a python group?
sed '/^@/!{G;/\n\n\n/{P;d;};s/[^\n]*//;h;d;}' data
--
John Savage (my news add
Sebastian Busch wrote:
> The task is:
>
> "Remove the first two lines that don't begin with "@" from a file."
awk 'BEGIN {c = 0} c < 2 && !/^@/ {c += 1; next} {print}' < mybeautifulfile
--
Roberto Bonvallet
--
http://mail.python.org/mailman/listinfo/python-list
Chetan wrote:
> Sebastian Busch <[EMAIL PROTECTED]> writes:
>
>> Steve Holden wrote:
>>> Sebastian Busch wrote:
[EMAIL PROTECTED] wrote:
> ... I would like to remove two lines from a file. ...
... grep -v ...
>>> ... show ...
>> grep -v "`grep -v "commentsymbol" yourfile | head -2`"
Sebastian Busch <[EMAIL PROTECTED]> writes:
> Steve Holden wrote:
>> Sebastian Busch wrote:
>>> [EMAIL PROTECTED] wrote:
... I would like to remove two lines from a file. ...
>>> ... grep -v ...
>> ... show ...
>
> grep -v "`grep -v "commentsymbol" yourfile | head -2`" yourfile
>
>
> i frankl
Steve Holden wrote:
> Sebastian Busch wrote:
>> [EMAIL PROTECTED] wrote:
>>> ... I would like to remove two lines from a file. ...
>> ... grep -v ...
> ... show ...
grep -v "`grep -v "commentsymbol" yourfile | head -2`" yourfile
i frankly admit that there is also 'head' invoved ;)
i really have
Sebastian Busch wrote:
> [EMAIL PROTECTED] wrote:
>
>>... I would like to remove two lines from a file.
>>...
>
>
> I am quite new myself -- but wouldn't grep -v do that easier (and
> perhaps faster)?
>
Kindly show how to use grep to solve this problem:
Remove the first two lines that don't
[EMAIL PROTECTED] wrote:
> ... I would like to remove two lines from a file.
> ...
I am quite new myself -- but wouldn't grep -v do that easier (and
perhaps faster)?
Greetings,
Sebastian.
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
> Dear all,
>
> I am quite new to python. I would like to remove two lines from a file.
The canonical way to do so (at least for text files - which is the case
here) is :
open the source file in read mode
open a tmp file in write mode
for each line in source file:
if
Thanks, I have learnt sth from the library BTW.
Regards
On Oct 25, 3:32 pm, "Jerry" <[EMAIL PROTECTED]> wrote:
> Very inelegant, but you get the idea:
>
> counter = 0
>
> f = open("test.txt")
> for line in f.readlines():
> if line[0] != "$" and counter < 2:
> counter += 1
> co
Very inelegant, but you get the idea:
counter = 0
f = open("test.txt")
for line in f.readlines():
if line[0] != "$" and counter < 2:
counter += 1
continue
else:
print line,
--
Jerry
--
http://mail.python.org/mailman/listinfo/python-list
Dear all,
I am quite new to python. I would like to remove two lines from a file.
The file starts with some comments, the comment sign is $. The file
structure is
$
$
$
$
$
$
$
.
.
.
.
$
line1
line 2
$
$
.
.
.
$
actual commands
I would like to delete those two lines at the very beginning of the
11 matches
Mail list logo