<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/8450" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2004-10-18T00:02:49-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/8450</id>

		<entry>
		<author><name><![CDATA[Ofloo]]></name></author>
		<updated>2004-10-18T00:02:49-04:00</updated>

		<published>2004-10-18T00:02:49-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=41971#p41971</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=41971#p41971"/>
		<title type="html"><![CDATA[Reading last 20 lines from file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=41971#p41971"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code>proc readLines {f n} {  if {![catch {open $f r} rf]} {    set c [read $rf]    set l [expr ([llength $c] - $n]) - 1];# i think llength includes 0 so..    if {$l &lt;= 0} {      foreach x [split $c \n] {        puts $x      }      close $rf      return     }    foreach x [split $c \n] {      if {[info exists i]} {        incr i      } else {      set i 0      }      if {($i &gt;= $l)} {        puts "$x"      }    }    close $rf  } else {    error "Couldn't open $f.."  }}readLines &lt;yourfile&gt; &lt;20&gt;</code></pre></div>i think this works haven't tested it tho<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3151">Ofloo</a> — Mon Oct 18, 2004 12:02 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[egghead]]></name></author>
		<updated>2004-10-16T00:22:14-04:00</updated>

		<published>2004-10-16T00:22:14-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=41911#p41911</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=41911#p41911"/>
		<title type="html"><![CDATA[Re: Reading last 20 lines from file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=41911#p41911"><![CDATA[
<blockquote class="uncited"><div>What would be the best way to go about reading the last 20 lines from a txt file?<br><br>The only thing I can think of is, check how many lines there are, and make it read the last 20 ones. Which involves a calculation for each line read...problem is - I'm not able to put it into code. Does anybody know a way to do this...or even a better way to read last 20 lines?<br><br>Thanks, later.</div></blockquote>If your file is not too big, you can use a simple procedure.<br><br>- [read] in the complete file at once<br>- [split] the file into a list around the newline character<br>- take the last 20 elements of that list<br><br>done.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=282">egghead</a> — Sat Oct 16, 2004 12:22 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2004-10-15T21:18:47-04:00</updated>

		<published>2004-10-15T21:18:47-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=41910#p41910</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=41910#p41910"/>
		<title type="html"><![CDATA[Reading last 20 lines from file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=41910#p41910"><![CDATA[
What would be the best way to go about reading the last 20 lines from a txt file?<br><br>The only thing I can think of is, check how many lines there are, and make it read the last 20 ones. Which involves a calculation for each line read...problem is - I'm not able to put it into code. Does anybody know a way to do this...or even a better way to read last 20 lines?<br><br>Thanks, later.<p>Statistics: Posted by Guest — Fri Oct 15, 2004 9:18 pm</p><hr />
]]></content>
	</entry>
	</feed>
