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

ファイルの先頭部分を表示します。

head オプション1 ファイルパス1
オプション1(任意) -c 値1 ファイルの先頭から(値1)バイトを表示 単位(バイト) b : 512 k : 1024 m : 1048576 -n 値1 ファイルの先頭から(値1)行を表示 ファイルパス1 表示するファイル

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

(例) オプション無し
実行結果
$ head /usr/include/stdio.h /* Define ISO C stdio on top of C++ iostreams. Copyright (C) 1991, 1994-2010, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful,

(例) オプション -c
実行結果
$ head -c 100 /usr/include/stdio.h ← 先頭から100バイト出力 /* Define ISO C stdio on top of C++ iostreams. Copyright (C) 1991, 1994-2010, 2011 Free Software $ head -c 1k /usr/include/stdio.h ← 先頭から1kバイト出力 /* Define ISO C stdio on top of C++ iostreams. Copyright (C) 1991, 1994-2010, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ /* * ISO C99 Standard: 7.19 Input/output <stdio.h> */ #ifndef _STDIO_H #if !defined __need_FILE && !defin

(例) オプション -n
実行結果
$ head -n 5 /usr/include/stdio.h ← 先頭から5行出力 /* Define ISO C stdio on top of C++ iostreams. Copyright (C) 1991, 1994-2010, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or