2012-01-22 2 views

답변

2

로그 파일의 한 줄 길이에 상한을 둘 수 있습니까? 그렇다면, 그것은 마지막 줄 얻기 위해 꽤 쉽게 : 그것은 정말 seek필요 아니라고

# 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] 

참고; 단지 원치 않는 파일의 대다수를 읽지 않아도됩니다.

+0

나는이 스크립트에 더 많은 것을 추가하거나 그냥 넣어서 놓아 두어야 할 필요가있다. 약 일주일에 .tcl과 eggdrop에 여전히 아무것도 작동하지 못할 수 있습니다. 감사합니다. – fright

+0

사실 그것은 필자가 마침내 얻은 것 같아요. hehe는이 도움에 대해 대단히 감사합니다. – fright

관련 문제