tailコマンド

UNIXサーバ構築 OnTheVMware

unixコマンドについて使用例を用いて解説
HOME > 基本操作コマンド >

tailコマンド

tailコマンド


スポンサードリンク


【説明】
ファイルの末尾の部分を表示する際に使用します。

tail は引数に与えられた FILE それぞれの末尾の部分 (デフォルトでは 10 行) を表 示する。 FILE が 1 つも与えられないと標準入力から読み込む。また FILE が ‘-’ だった場合には、そのファイルには標準入力が用いられる。

【構文】
tail [オプション] [ファイル名]

例 /var/log/messageの末尾5行を表示する。
[root@localhost ~]# tail -n 5 /var/log/messages
Jun 18 09:24:16 localhost sshd(pam_unix)[4764]: session closed for user root
Jun 18 09:24:53 localhost sshd(pam_unix)[5832]: session opened for user root by (uid=0)
Jun 18 09:56:04 localhost passwd(pam_unix)[6255]: password changed for test
Jun 18 10:06:22 localhost sshd(pam_unix)[5832]: session closed for user root
Jun 18 10:08:18 localhost sshd(pam_unix)[6400]: session opened for user root by (uid=0)

例 リアルタイムで/var/log/messageの内容を表示する。
[root@localhost ~]# tail -f /var/log/messages
Jun 18 08:31:52 localhost su(pam_unix)[4920]: session closed for user test
Jun 18 08:32:06 localhost su(pam_unix)[4943]: session opened for user test by root(uid=0)
Jun 18 08:32:21 localhost su(pam_unix)[4943]: session closed for user test
Jun 18 08:32:25 localhost su(pam_unix)[4963]: session opened for user test by root(uid=0)
Jun 18 08:32:29 localhost su(pam_unix)[4963]: session closed for user test
Jun 18 09:24:16 localhost sshd(pam_unix)[4764]: session closed for user root
Jun 18 09:24:53 localhost sshd(pam_unix)[5832]: session opened for user root by (uid=0)
Jun 18 09:56:04 localhost passwd(pam_unix)[6255]: password changed for test
Jun 18 10:06:22 localhost sshd(pam_unix)[5832]: session closed for user root
Jun 18 10:08:18 localhost sshd(pam_unix)[6400]: session opened for user root by (uid=0)

スポンサードリンク
 HOME / 免責事項 / サイトマップ /  問い合わせ
Copyright (C) 2008  UNIXサーバ構築 OnTheVMware  All rights reserved





スポンサードリンク