-
Notifications
You must be signed in to change notification settings - Fork 1
/
join.1
152 lines (111 loc) · 5.04 KB
/
join.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
JOIN(1) Human68k ITA TOOLBOX User's Manual JOIN(1)
名称
join - 2つのファイルの行を合併する
形式
join [ -1 fieldno ] [ -2 fieldno ] [ -j[1|2] fieldno ]
[ -a {1|2} ] [ -v {1|2} ] [ -o fileno.fieldno ... ]
[ -e string ] [ -t character ] [ -Z ] [ -- ]
file1 file2
解説
join は file1 と file2 の内容を読み取り,両ファイル間で互い
に共通のフィールドを含む 2行を 1行に合併して標準出力に出力
します.
file1 または file2 として‘-’を指定すると標準入力から読み取
ります.ただし両方に標準入力を指定することはできません.
join は改行(LF および CRLF)を区切りとして入力を行に分解し,
さらに -t オプションで指定されるフィールド区切 character
(およびその連続)を区切りとしてフィールドに分割します.-t
オプションを指定しない場合,フィールド区切文字はスペースと水
平タブです.
特にオプションを指定しなければ,join は file1 と file2 のそ
れぞれの行の最初のフィールドが共通であるかどうか比較し,もし
一致していれば,その 2つの行を 1つの行に合併して標準出力に出
力します.比較対象フィールドはファイル毎にオプションで指定す
ることができます.両ファイルは,比較対象フィールドについて予
め文字コード順にソートされている必要があります.
-o オプションを指定しなければ,出力行は,共通フィールド,
file1 の行の残りのフィールド,file2 の行の残りのフィールド,
そして改行(CRLF)が,この順序で連結されたものです.-o オプ
ションによって出力のフィールドの順番を指定することができます.
フィールドとフィールドの間には 1文字の character が出力され
ます.-t オプションが指定されていない場合には character の代
わりに 1文字のスペースが出力されます.
join には次のオプションがあります.
-1 fieldno
-j1 fieldno
file1 において fieldno 番目のフィールドを比較対象フィー
ルドとします.fieldno は 1 から始まる符号なし10進整数で
す.
-2 fieldno
-j2 fieldno
file2 において fieldno 番目のフィールドを比較対象フィー
ルドとします.fieldno は 1 から始まる符号なし10進整数で
す.
-j fieldno
file1 と file2 の両方において fieldno 番目のフィールド
を比較対象フィールドとします.fieldno は 1 から始まる符
号なし10進整数です.fieldno が 1 または 2 である場合に
は -j と fieldno との間にスペースが必要です.
-a1
-a 1
file1 のすべての行から出力行を生産します.
-a2
-a 2
file2 のすべての行から出力行を生産します.
-v1
-v 1
file1 の行のうち,file2 と合併できない行のみから出力行
を生産します.-a オプションは無効となります.
-v2
-v 2
file2 の行のうち,file1 と合併できない行のみから出力行
を生産します.-a オプションは無効となります.
-o { fileno.fieldno } ...
出力行内のフィールドの順番を指定します.
fileno は 1 ならば file1 の行を,2 ならば file2 の行を
表します.fieldno は 1 から始まる符号なし10進整数で,そ
の行のフィールド番号を表します.
たとえば -o 1.2 2.3 1.1 2.2 では,file1 の 2番目のフィー
ルド,file2 の 3番目のフィールド,file1 の 1番目のフィー
ルド,file2 の 2番目のフィールドの 4つのフィールドが,
この順序で出力されます.
-o 1.2 2.3 -o 1.1 2.2 のように -o オプションを複数指定
することもできます.この場合は -o 1.2 2.3 1.1 2.2 と等
価です.
指定のフィールドが存在しない場合は空文字列かまたは -e
オプションで指定される string が出力されます.
-e string
空の出力フィールドを string に置き換えます.
-t character
文字 character を入出力におけるフィールド区切文字としま
す.character は任意の 1バイト文字またはシフトJIS 2バイ
ト文字です.-t オプションを指定しなければ,入力において
はスペースと水平タブ,出力においてはスペースがフィール
ド区切文字となります.
-Z いかなる入力からも,^Z (control-Z) コードを EOF と見な
して入力を打ち切ります.通常は,入力が cooked モードの
キャラクタ・デバイス(CON など)である場合にのみ,^D か
または ^Z を読み取ると,それを EOF コードと見なして入力
を打ち切ります.
関連事項
cmp(1), comm(1), cut(1), diff(1), paste(1), sdiff(1),
sort(1), uniq(1)
診断
何らかのエラーがあったときにはエラー・メッセージが標準エラー
出力に出力されます.
終了ステータスとしては,引数の記述に間違いがあった場合には 1,
指定のファイルが存在しなかったりオープンできなかった場合には
2,出力エラーやメモリ不足など,システムの問題により正常に実
行できなかった場合には 3,すべてが正常に終了したならば 0 が
返ります.^C などによって中断したときの終了ステータスは OS
の仕様によります.
不具合
cooked モードのキャラクタ・デバイスからは,^D や ^Z を EOF
としてではなくデータとして入力することはできません.
CON からは行単位で入力されますので,^D あるいは ^Z の後にも
改行が必要です.
バージョン
1.0
制作・著作
Copyright(C)1995 by 板垣 史彦 (Itagaki Fumihiko)
1.0 Last change: 29 Jan 1995 Itagaki Fumihiko