-
Notifications
You must be signed in to change notification settings - Fork 1
/
uniq.1
127 lines (89 loc) · 4.16 KB
/
uniq.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
REV(1) Human68k ITA TOOLBOX User's Manual REV(1)
名称
uniq - 反復している行を抽出する
形式
uniq [ -udcSBCZ ] [ -f #skip-fields ] [ -s #skip-chars ]
[ -w #check-chars ] [ -#skip-fields ] [ +#skip-chars ]
[ -- ] [ input [ output ] ] ...
解説
uniq は input を読み取り,隣合う行を比較しながら output に出
力します.
-u オプションを指定すると,前後に反復の無い行のみが出力され
ます.-d オプションを指定すると,反復した行のうちの最初の行
のみが出力されます.通常は両方の出力を合わせたものが出力され
ます.
input が省略されている場合,または input が‘-’である場合に
は標準入力から読み取ります.output が省略されている場合,ま
たは output が‘-’である場合には標準出力に出力します.
uniq には次のオプションがあります.
-u 前後に反復の無い行のみを出力します.
-d 反復した行のうちの最初の行のみを出力します.
-c 各行が現れる個数を各行(反復の無い行および反復した行の
うちの最初の行)の前につけて出力します.このオプション
を指定した場合,-u オプションおよび -d オプションは無効
です.
-f #skip-fields
行を比較する際に各行の最初の #skip-fields フィールドを
それぞれの前にあるタブや空白の連続とともに無視(スキッ
プ)します.#skip-fields 引数は 10進表記の正整数です.
フィールドは,タブかスペースで区切られた,タブでもスペー
スでもない文字が 1文字以上連続している文字列です.
#skip-fields フィールドよりも短い行は空文字列として比較
されます.
-S 行を比較する際に各行の最初のタブやスペースの連続を無視
(スキップ)します.-f オプションのスキップはこれよりも
先に行われます.
-s #skip-chars
行を比較する際に各行の最初の #skip-chars 文字(バイト)
を無視(スキップ)します.#skip-chars 引数は 10進表記の
正整数です.-f オプションおよび -S オプションのスキップ
はこれよりも先に行われます.スキップする文字数よりも短
い行は空文字列として比較されます.
-w #check-chars
フィールドや文字をスキップした後,行を比較する際に
#check-chars 文字(バイト)を超える分は比較せず無視しま
す.
-#skip-fields
-f #skip-fields と同じです.
+#skip-chars
-s #skip-fields と同じです.
-B 決して ^J コードの ^M^J への変換を行いません.通常は,
出力が cooked モードのキャラクタ・デバイス(CON や PRN
など)である場合には,^M に続いていない ^J コードを
^M^J に変換して出力します.
-C -B オプションと逆に,^M に続いていない ^J コードを常に
^M^J に変換して出力します.
-Z いかなる入力からも,^Z (control-Z) コードを EOF と見な
して入力を打ち切ります.通常は,入力が cooked モードの
キャラクタ・デバイス(CON など)である場合にのみ,^D か
または ^Z を読み取ると,それを EOF コードと見なして入力
を打ち切ります.
関連事項
comm(1), sort(1)
診断
何らかのエラーがあったときにはエラー・メッセージが標準エラー
出力に出力されます.
終了ステータスとしては,引数の記述に間違いがあった場合には 1,
ファイルがオープンできなかったり入力に失敗した場合には 2,出
力エラーやメモリ不足など,システムの問題により正常に実行でき
なかった場合には 3,すべてが正常に終了したならば 0 が返りま
す.^C などによって中断したときの終了ステータスは OS の仕様
によります.
注意
output は input と別のファイルでなければなりません.もし同じ
ファイルを指定すると uniq が input からの読み取りを開始する
前に input の内容が失われることになります.
同様に,シェルから uniq foo > foo のような形で実行すると,
uniq が起動する前に foo の内容が失われてしまうことになります.
シェルはコマンドを実行する前に入出力の切り替えを行うというこ
とに注意してください.
不具合
cooked モードのキャラクタ・デバイスからは,^D や ^Z を EOF
としてではなくデータとして入力することはできません.
CON からは行単位で入力されますので,^D あるいは ^Z の後にも
改行が必要です.
バージョン
1.0
制作・著作
Copyright(C)1995 by 板垣 史彦 (Itagaki Fumihiko)
1.0 Last change: 15 Jan 1995 Itagaki Fumihiko