0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Linucレベル1勉強メモ #29

Posted at

# 第三章 GNUとUnixのコマンド

練習問題3.4
/var/log/messagesファイルの末尾20行を表示したい場合、下線部に当てはまるコマンドを記述してください。

____ -n 20 /var/log/messages

(解答)tail

(解説)ファイルの末尾を表示するにはtailコマンドを使います。-nオプションで表示する行すうを指定しますが、「-20」のように指定しても構いません。行すうを指定しないと、末尾10行が表示されます。
「-f」オプションを使うと、ファイルの末尾を表示し続け、ファイルの末尾に行が追加されるとリアルタイムで表示します。ログファイルをリアルタイムで監視する時などに便利です。

書式 tail [オプション] [ファイル名]
tailコマンドの主なオプション

  1. -n 行数
    末尾から指定された行数分だけ表示する
  2. -行数
    末尾から指定された行数分だけ表示する(推奨されていない)
  3. -c バイト数
    末尾から指定されたバイト数だけ表示する
  4. -f --follow
    ファイルの末尾に追加された行を表示し続けr
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?