Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

change and remove a line

34 views
Skip to first unread message

Andre

unread,
Jan 27, 2018, 9:50:53 AM1/27/18
to
Hi Everyone,

How to change a string for line 1 and remove line 2 until 3.
set fd [open $data.dat r]

Thanks in advance!

Gerald Lester

unread,
Jan 27, 2018, 12:43:11 PM1/27/18
to
The same way you do it in any programming language.

Is this a homework assignment?

--
+----------------------------------------------------------------------+
| Gerald W. Lester, President, KNG Consulting LLC |
| Email: Gerald...@kng-consulting.net |
+----------------------------------------------------------------------+

Rich

unread,
Jan 27, 2018, 3:00:23 PM1/27/18
to
Gerald Lester <Gerald...@kng-consulting.net> wrote:
> On 01/27/2018 08:50 AM, Andre wrote:
>> Hi Everyone,
>>
>> How to change a string for line 1 and remove line 2 until 3.
>> set fd [open $data.dat r]
>>
>> Thanks in advance!
>>
>
> The same way you do it in any programming language.
>
> Is this a homework assignment?

This simple a question sounds *very* much like a homework assignment.

Andre

unread,
Jan 27, 2018, 8:51:33 PM1/27/18
to
Ronald and rich sorry for that. I have try using below script but why the result always add two lines (blank string) on the end of actual string?

set lines [lrange $lines 2 end]
puts $fp [join $lines “\n”]

Thanks for helps!

Rich

unread,
Jan 28, 2018, 1:07:05 AM1/28/18
to
Andre <geom...@gmail.com> wrote:
> Ronald and rich sorry for that. I have try using below script but why
> the result always add two lines (blank string) on the end of actual
> string?
>
> set lines [lrange $lines 2 end]
> puts $fp [join $lines ?\n?]

No idea, since you've given us not enough info to give any answer.

Christian Gollwitzer

unread,
Jan 28, 2018, 3:20:45 AM1/28/18
to
Am 28.01.18 um 02:51 schrieb Andre:
> Ronald and rich sorry for that. I have try using below script but why the result always add two lines (blank string) on the end of actual string?
>
> set lines [lrange $lines 2 end]
> puts $fp [join $lines “\n”]

puts always adds an extra newline. If you want to stop it, use
puts -nonewline $fd $something. [split \n] converts every line into a
string. If you have a regular file, which ends in \n, it will give you
an empty string at the end.
Christian
0 new messages