-
Notifications
You must be signed in to change notification settings - Fork 1
/
head.1
138 lines (92 loc) · 3.98 KB
/
head.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
HEAD(1) Human68k ITA TOOLBOX User's Manual HEAD(1)
名称
head - ファイルの先頭部分を出力する
形式
head [ -qvBCZ ] { [ -count[ckl] ] [ -- ] [ file ] } ...
解説
head は,各 file を順次読み取り,それぞれの先頭の count 数だ
けの部分を標準出力に出力します.count は10進整数です.count
の直後には,count の単位を示す次の文字を付加することができま
す.
c 文字(バイト)単位
k 1K(=1024)バイト単位
l 行単位
これらの文字が付加されていなければ,count は行単位となります.
count が指定されない場合のデフォルトは 10(行)です.
file の長さが count よりも短い場合には file の内容がすべて出
力されます.
file が 1つも指定されていない場合,または file が‘-’である
場合には標準入力から読み取りを行います.file がオープンでき
ないときにはエラー・メッセージを標準エラー出力に出力して処理
を中止します.
指定 file が 1つの場合,通常は次のように file の内容だけが出
力されます.
% head -1 file1
これは file1 の 1行目です.
%
最初の file の後ろにさらに引数が続いている場合には,次のよう
に各 file の内容の前に‘==> file <==’という形のヘッダが出力
されます.(% はシェルのプロンプトです)
% head -1 file1 file2
==> file1 <==
これは file1 の 1行目です.
==> file2 <==
これは file2 の 1行目です.
%
このように,2つ目以降のヘッダには改行も伴います.
ファイル毎に別々の count を指定することができます.例を示し
ます.
% head -1 file1 -2 file2
==> file1 <==
これは file1 の 1行目です.
==> file2 <==
これは file2 の 1行目です.
これは file2 の 2行目です.
%
入力が cooked モードのキャラクタ・デバイス(CON など)である
場合,^D (control-D) かまたは ^Z を読み取ると,それを EOF コー
ドと見なして入力を打ち切ります.
入力がファイルである場合に,テキストとバイナリとを区別して考
える必要はありません.count が行単位であるとき,head は,通
常,出力が cooked モードのキャラクタ・デバイス(CON や PRN
など)である場合にのみ,^M に続いていない ^J コードを ^M^J
に変換して出力します.count がバイト単位であるときには,どの
場合にもこの変換は行われません.
head に指定できるオプションを以下に示します.
-q ヘッダを決して出力しません.
-v ヘッダを必ず出力します.
-B 決して ^J コードの ^M^J への変換を行いません.
-C count が行単位であるとき,^M に続いていない ^J コードを
常に ^M^J に変換して出力します.count がバイト単位であ
るときには変換しません.
-Z いかなる入力からも,^Z コードを EOF と見なして入力を打
ち切ります.
これらのオプションは -q -Z のようにそれぞれ単独に記述するこ
ともできますし,-qZ のように連結して指定することもできます.
-q オプションと -v オプションの両方を指定した場合には,最後
に指定した一方が有効となります.
-B オプションと -C オプションの両方を指定した場合には,最後
に指定した一方が有効となります.
引数‘--’は,次の引数を file であると解釈させます.引数‘-’
は標準入力を意味し,file として解釈されます.
関連事項
cat(1), tail(1), tee(1), more(1)
診断
何らかのエラーがあったときにはエラー・メッセージが標準エラー
出力に出力されます.
終了ステータスとしては,引数の記述に間違いがあった場合には 1,
ファイルがオープンできなかったり入力に失敗した場合には 2,出
力エラーやメモリ不足など,システムの問題により正常に実行でき
なかった場合には 3,すべてが正常に終了したならば 0 が返りま
す.^C などによって中断したときの終了ステータスは OS の仕様
によります.
不具合
cooked モードのキャラクタ・デバイスからは,^D や ^Z を EOF
としてではなくデータとして入力することはできません.
CON からは行単位で入力されますので,^D あるいは ^Z の後にも
改行が必要です.
バージョン
1.5
制作・著作
Copyright(C)1993-94 by 板垣 史彦 (Itagaki Fumihiko)
1.5 Last change: 10 Oct 1993 Itagaki Fumihiko