Created
October 11, 2010 04:05
-
-
Save ksky/619953 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// g100pon #25 tail -f | |
def input | |
if (args.size()) { | |
def file = new File(args[0]) | |
input = new FileReader(file) | |
def pos = file.size() - 80 * 10 // 十行分(かなり適当) | |
if (pos > 0) { | |
input.skip(pos) // ラスト10行あたりまでスキップ | |
input.readLine() // 中途半端な行を空読み | |
} | |
} else { | |
// ファイルが指定されなければ標準入力から読む | |
input = new InputStreamReader(System.in) | |
} | |
def reader = new BufferedReader(input) | |
while (true) { | |
while ((line = reader.readLine()) != null) { | |
println line | |
} | |
Thread.sleep(1000) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment