Loose-Info.com
Last Update 2014/03/11
TOP - Unix系OS - Linux - tail(1)

ファイルの末尾部分を表示します。

tail オプション1 ファイルパス1 オプション1(任意) -c 値1 ファイルの末尾から(値1)バイトを表示 「+」を(値1)に付けるとファイルの先頭から(値1)バイトの位置からの出力 単位(バイト) b : 512 k : 1024 m : 1048576 -f ファイルの読み込みを継続し、追加データを表示 ※使用例無し -n 値1 ファイルの末尾から(値1)行を表示 「+」を(値1)に付けるとファイルの先頭から(値1)行の位置からの出力 ファイルパス1 表示するファイル

※ オプションなどは個人的に重要と考えられるものを記述しており、記載の無いものは、manページや関連書籍などを参照願います。
※ 実行例の記述は、不要と考えられる部分の削除などの修正を行ったものを掲載しています。
※ 実行例の実行環境はUbuntu 12.10です。

(例)オプション無し
実行結果
$ tail /usr/include/stdio.h #endif #ifdef __LDBL_COMPAT # include <bits/stdio-ldbl.h> #endif __END_DECLS #endif /* <stdio.h> included. */ #endif /* !_STDIO_H */

(例) オプション -c
実行結果
$ tail -c 100 /usr/include/stdio.h ← 末尾から100バイト出力 <bits/stdio-ldbl.h> #endif __END_DECLS #endif /* <stdio.h> included. */ #endif /* !_STDIO_H */ $ tail -c 1k /usr/include/stdio.h ← 末尾から1kバイト出力 ership of STREAM but do not block if it is not possible. */ extern int ftrylockfile (FILE *__stream) __THROW __wur; /* Relinquish the ownership granted for STREAM. */ extern void funlockfile (FILE *__stream) __THROW; #endif /* POSIX || misc */ #if defined __USE_XOPEN && !defined __USE_XOPEN2K && !defined __USE_GNU /* The X/Open standard requires some functions and variables to be declared here which do not belong into this header. But we have to follow. In GNU mode we don't do this nonsense. */ # define __need_getopt # include <getopt.h> #endif /* X/Open, but not issue 6 and not for GNU. */ /* If we are compiling with optimizing read this file. It contains several optimizing inline functions and macros. */ #ifdef __USE_EXTERN_INLINES # include <bits/stdio.h> #endif #if __USE_FORTIFY_LEVEL > 0 && defined __extern_always_inline # include <bits/stdio2.h> #endif #ifdef __LDBL_COMPAT # include <bits/stdio-ldbl.h> #endif __END_DECLS #endif /* <stdio.h> included. */ #endif /* !_STDIO_H */ $ tail -c +31200 /usr/include/stdio.h ← 先頭から31200バイトの位置から出力 but not issue 6 and not for GNU. */ /* If we are compiling with optimizing read this file. It contains several optimizing inline functions and macros. */ #ifdef __USE_EXTERN_INLINES # include <bits/stdio.h> #endif #if __USE_FORTIFY_LEVEL > 0 && defined __extern_always_inline # include <bits/stdio2.h> #endif #ifdef __LDBL_COMPAT # include <bits/stdio-ldbl.h> #endif __END_DECLS #endif /* <stdio.h> included. */ #endif /* !_STDIO_H */

(例) オプション -n
実行結果
$ tail -n 5 /usr/include/stdio.h ← 末尾から5行出力 __END_DECLS #endif /* <stdio.h> included. */ #endif /* !_STDIO_H */ $ tail -n +935 /usr/include/stdio.h ← 先頭から935行目から出力 #endif #ifdef __LDBL_COMPAT # include <bits/stdio-ldbl.h> #endif __END_DECLS #endif /* <stdio.h> included. */ #endif /* !_STDIO_H */