Skip to content

Instantly share code, notes, and snippets.

@ksky
Created October 11, 2010 04:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ksky/619953 to your computer and use it in GitHub Desktop.
Save ksky/619953 to your computer and use it in GitHub Desktop.
// 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