windowsで「tails」コマンドを実行する

windowsで「tails」コマンドを実行する

windowsで「tails」コマンドを実行する手順を記述してます。

環境

  • OS windows10 pro

「tails」コマンドを実行

「powershell」を使用して、「tails」と同等のコマンドを実行することが可能です。

Get-Content ファイル -Wait -Tail 行数

例えば「test.log」というファイルを、後ろから10行のみリアルタイムに取得したい場合は、以下となります。

Get-Content .\test.log -Wait -Tail 10

「test.log」

testlog1
testlog2
testlog3
testlog4
testlog5
testlog6
testlog7
testlog8
testlog9
testlog10
testlog11
testlog12
testlog13
testlog14
testlog15

実行結果

vscode上でも、実行できるので便利です。
※ファイル更新時は全ての行が読み取られます。

全行表示されるのが嫌な場合は、「Bash on Ubuntu on Windows」を使用すれば可能です。

# mntに移動
cd /mnt

# ドライブ確認
ls
# ドライブを選択
c  d  e  f  g

# 対象ドライブに移動
cd c

# 対象のファイルに、tailsを使用する
tail -f 10 test.log