$ tail -f testfile
このコマンドは、指定されたファイルの最新項目をリアルタイムで表示する必要があります。そうですか?しかし、そのようなことは起こりませんでした。私の意図が間違っている場合は訂正してください...
新しいファイル「aaa」を作成し、1行のテキストを追加して閉じました。次に、次のコマンドを実行します(最初の行)。
$ tail -f aaa
xxx
xxa
axx
最後の3行はaaaファイルの内容です。これで、コマンドはまだ実行されているので(使用しているように-f
)GUIを介してaaaファイルを開き、手動でより多くの行を追加し始めます。ただし、端末にはファイルに追加された新しい行は表示されません。
どうなりますか?このtail -f
コマンドは、システムでのみ作成された新しいエントリのみを表示しますか? (ログファイルなど)
ベストアンサー1
~からtail(1)
マニュアルページ:
With --follow (-f), tail defaults to following the file descriptor, which means that even if a tail’ed file is renamed, tail will continue to track its end. This default behavior is not desirable when you really want to track the actual name of the file, not the file descrip- tor (e.g., log rotation). Use --follow=name in that case. That causes tail to track the named file in a way that accommodates renaming, removal and creation.
テキストエディタで元のファイルの名前を変更または削除し、新しいファイルを同じファイル名で保存しています。代わりに使用してください-F
。