Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
28
Help us understand the problem. What is going on with this article?
@ymko

Windowsでtail -f

More than 5 years have passed since last update.

まさにそのままのがggったらあった。

Windows で tail -f する方法 - maruko2 Note.

Get-Content コマンドレットのエイリアス[1]として cat, gc, type が登録されているので、cat でも同じ結果になる。
cat "LogFiles\Firewall\pfirewall.log" -wait -tail 10

C:\tmp> powershell
Windows PowerShell
Copyright (C) 2014 Microsoft Corporation. All rights reserved.
PS C:\tmp> cat a.txt -wait
aaaaa
aaa
aa
aa

golangではgotailというパッケージがあるらしい

$ go get github.com/ActiveState/tail
$ cp src/github.com/ActiveState/tail/cmd/gotail/gotail.go .
$ go build gotail.go
$ GOOS=windows GOARCH=amd64 go build gotail.go
$ ./gotail -h
Usage of ./gotail:
  -F=false: follow, and track file rename/rotation
  -f=false: wait for additional data to be appended to the file
  -max=0: max line size
  -n=0: tail from the last Nth location
  -p=false: use polling, instead of inotify
$ ./gotail -f a.txt
aaaaa
aaa
aa
aa

Windowsでも動く

PS C:\tmp> .\gotail.exe -h
Usage of C:\tmp\gotail.exe:
  -F=false: follow, and track file rename/rotation
  -f=false: wait for additional data to be appended to the file
  -max=0: max line size
  -n=0: tail from the last Nth location
  -p=false: use polling, instead of inotify
PS C:\tmp> .\gotail.exe -f a.txt
aaaaa
aaa
aa
aa

参考

複数ファイルの tail -f を heroku logs っぽく表示する「9t」 - Thanks Driven Life
http://gongo.hatenablog.com/entry/2015/03/09/221231
↑ソースはそんなに長くないのでgolangの勉強になる
ActiveState/tail
https://github.com/ActiveState/tail

28
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
28
Help us understand the problem. What is going on with this article?