2012-01-22 52 views

回答

2

是否有可能把日誌文件的一行的長度的上限?如果是這樣,這是很容易得到的最後一行:

# A nice fat upper bound! 
set upperBoundLength 1024 

# Open the log file 
set f [open $logfile r] 
# Go to some distance from the end; catch because don't care about errors here 
catch {seek $f -$upperBoundLength end} 
# Read to end, stripping trailing newline 
set data [read -nonewline $f] 
# Hygiene: close the logfile 
close $f 
# Get the last line 
set lastline [lindex [split $data "\n"] end] 

請注意,這不是真的必要seek;它只是讓你不必閱讀你大概不想要的大部分文件。

+0

我非常喜歡這個,我需要添加更多這個腳本,或者只是把它放進去,讓它去吧。我進入.tcl和eggdrop一週左右,仍然無法做任何工作..再次感謝 – fright

+0

實際上它似乎ive終於得到它嘿非常感謝你的幫助 – fright