Usage: sort [OPTION]... [FILE]...
or: sort [OPTION]... --files0-from=F
Write sorted concatenation of all FILE(s) to standard output.
長いオプションに必須の引数は短いオプションにも必須です.
Ordering options:
-b, --ignore-leading-blanks ignore leading blanks
-d, --dictionary-order consider only blanks and alphanumeric characters
-f, --ignore-case fold lower case to upper case characters
-g, --general-numeric-sort compare according to general numerical value
-i, --ignore-nonprinting consider only printable characters
-M, --month-sort compare (unknown) < `JAN' < ... < `DEC'
-h, --human-numeric-sort compare human readable numbers (e.g., 2K 1G)
-n, --numeric-sort compare according to string numerical value
-R, --random-sort sort by random hash of keys
--random-source=FILE get random bytes from FILE
-r, --reverse reverse the result of comparisons
--sort=WORD sort according to WORD:
general-numeric -g, human-numeric -h, month -M,
numeric -n, random -R, version -V
-V, --version-sort natural sort of (version) numbers within text
Other options:
--batch-size=NMERGE merge at most NMERGE inputs at once;
for more use temp files
-c, --check, --check=diagnose-first check for sorted input; do not sort
-C, --check=quiet, --check=silent like -c, but do not report first bad line
--compress-program=PROG compress temporaries with PROG;
decompress them with PROG -d
--files0-from=F read input from the files specified by
NUL-terminated names in file F;
If F is - then read names from standard input
-k, --key=POS1[,POS2] start a key at POS1 (origin 1), end it at POS2
(default end of line)
-m, --merge merge already sorted files; do not sort
-o, --output=FILE write result to FILE instead of standard output
-s, --stable stabilize sort by disabling last-resort comparison
-S, --buffer-size=SIZE use SIZE for main memory buffer
-t, --field-separator=SEP use SEP instead of non-blank to blank transition
-T, --temporary-directory=DIR use DIR for temporaries, not $TMPDIR or /tmp;
multiple options specify multiple directories
-u, --unique with -c, check for strict ordering;
without -c, output only the first of an equal run
-z, --zero-terminated 文字列の最後に改行でなくヌル文字を付加
--help この使い方を表示して終了
--version バージョン情報を表示して終了
POS is F[.C][OPTS], where F is the field number and C the character position
in the field; both are origin 1. If neither -t nor -b is in effect, characters
in a field are counted from the beginning of the preceding whitespace. OPTS is
one or more single-letter ordering options, which override global ordering
options for that key. If no key is given, use the entire line as the key.
SIZE may be followed by the following multiplicative suffixes:
メモリの % 1%, b は 1, K は 1024 (標準) のように M, G, T, P, E, Z, T.
*** 警告 ***
環境変数によって指定されたロカールで並び替えの順番が変わります.
本来のバイト単位の数値で昔ながらの並び替え順にしたいならば LC_ALL=C を指定.
Report sort bugs to bug-coreutils@gnu.org
GNU coreutils home page:
Usage: sort [OPTION]... [FILE]...
or: sort [OPTION]... --files0-from=F
Write sorted concatenation of all FILE(s) to standard output.
Mandatory arguments to long options are mandatory for short options too.
Ordering options:
-b, --ignore-leading-blanks ignore leading blanks
-d, --dictionary-order consider only blanks and alphanumeric characters
-f, --ignore-case fold lower case to upper case characters
-g, --general-numeric-sort compare according to general numerical value
-i, --ignore-nonprinting consider only printable characters
-M, --month-sort compare (unknown) < `JAN' < ... < `DEC'
-h, --human-numeric-sort compare human readable numbers (e.g., 2K 1G)
-n, --numeric-sort compare according to string numerical value
-R, --random-sort sort by random hash of keys
--random-source=FILE get random bytes from FILE
-r, --reverse reverse the result of comparisons
--sort=WORD sort according to WORD:
general-numeric -g, human-numeric -h, month -M,
numeric -n, random -R, version -V
-V, --version-sort natural sort of (version) numbers within text
Other options:
--batch-size=NMERGE merge at most NMERGE inputs at once;
for more use temp files
-c, --check, --check=diagnose-first check for sorted input; do not sort
-C, --check=quiet, --check=silent like -c, but do not report first bad line
--compress-program=PROG compress temporaries with PROG;
decompress them with PROG -d
--files0-from=F read input from the files specified by
NUL-terminated names in file F;
If F is - then read names from standard input
-k, --key=POS1[,POS2] start a key at POS1 (origin 1), end it at POS2
(default end of line)
-m, --merge merge already sorted files; do not sort
-o, --output=FILE write result to FILE instead of standard output
-s, --stable stabilize sort by disabling last-resort comparison
-S, --buffer-size=SIZE use SIZE for main memory buffer
-t, --field-separator=SEP use SEP instead of non-blank to blank transition
-T, --temporary-directory=DIR use DIR for temporaries, not $TMPDIR or /tmp;
multiple options specify multiple directories
-u, --unique with -c, check for strict ordering;
without -c, output only the first of an equal run
-z, --zero-terminated end lines with 0 byte, not newline
--help display this help and exit
--version output version information and exit
POS is F[.C][OPTS], where F is the field number and C the character position
in the field; both are origin 1. If neither -t nor -b is in effect, characters
in a field are counted from the beginning of the preceding whitespace. OPTS is
one or more single-letter ordering options, which override global ordering
options for that key. If no key is given, use the entire line as the key.
SIZE may be followed by the following multiplicative suffixes:
% 1% of memory, b 1, K 1024 (default), and so on for M, G, T, P, E, Z, Y.
With no FILE, or when FILE is -, read standard input.
*** WARNING ***
The locale specified by the environment affects sort order.
Set LC_ALL=C to get the traditional sort order that uses
native byte values.
Report sort bugs to bug-coreutils@gnu.org
GNU coreutils home page:
SORT(1) SORT(1)
名前
sort - テキストファイルをソートする
書式
sort [-cm] [-bdfginruzM] [+POS1[-POS2] [-o OUTFILE] [-t SEPARATOR] [-k
POS1[,POS2] [-K POS1[,POS2] [-S SIZE] [-T TEMPDIR] [--reverse]
[FILE...]
sort [--help] [--version]
説明
sort は与えられた各 FILE をソート・マージ・比較する。結果は結合されて標
準出力に書き出される。 FILE が一つも与えられないと標準入力から読み込 む
。また FILE が ‘-’ だった場合には、そのファイルには標準入力が用いられる
。
GNU sort は (他の GNU ユーティリティと同じく) 入力ファイルの行の長さ や
、 行あたりのバイト数に制限はない。また入力ファイルの最後が改行でなけれ
ば、 sort は黙って改行を一つ追加する。
エラーが起こると、 sort はステータス 2 で終了する。
環境変数 TMPDIR が設定されていると、 sort は一時ファイルの置き場所と し
て、デフォルトの /tmp の代わりにそのディレクトリを用いる。オプション -T
TEMPDIR でも一時ファイルを置くディレクトリを指定できる。オプションは 環
境変数より優先される。
-k や + オプションでのソートフィールドの場所指定は、 F.C という形式で行
う。ここで F は用いるフィールドの番号で、 C は先頭の文字の番号を、そ の
フ ィールドの先頭 (+POS の場合) あるいは直前のフィールドの末尾 (-POS の
場合) から数えた数字である。 .C が省略された場合は、フィールドの先頭 文
字 になる。 -b オプションが指定されると、フィールド指定の .C の部分は、
そのフィールドの空白でない最初の文字 (+POS の場合) あるいは直前のフィー
ルドの末尾以降の空白でない最初の文字 (-POS の場合) から数えられる。
ソートキーのオプションには、出力順序オプション (output ordering option)
を含めることもでき、その場合はグローバルな順序オプションはそのフィー ル
ド には用いられない。 -b オプションはフィールド指定の +POS と -POS のど
ちらか片方にも、あるいは両方にも、独立に効力を及ぼすことができる 。 -b
が グローバルなオプションから継承されたものである場合は、両方に影響する
。キーは複数のフィールドにまたがってもかまわない。
オプション
動作モード
sort のデフォルトの動作はソート動作である。これは以下のオプションによっ
て変更できる。
-c 与えられたファイルがすでにソートされているかどうかをチェックする
。ソートされていないものがあった場合は、エラーメッセージを表示し
てステータス 1 で終了する。それ以外の場合は正常終了する。
-m 与えられたファイル群をまとめてソートしてマージする。入力ファイル
は事前にそれぞれソートされていなければならない。マージ動作ではな
く、ソート動作を複数ファイルにまとめて行うこともできる。マージ動
作が提供されているのは、 (これでよい場合は) こちらの方が高速だか
らである。
行 のペアは以下のように比較される。キーフィールドが指定されている場合は
、 sort は順序オプションによってコマンドラインから指定された順に、そ れ
ぞ れの行からの各フィールドを比較する。比較動作は違いを発見するか全ての
フィールドを尽くすまで継続される。
グローバルオプションの ‘-bdfinrM’ のいずれかが指定されており、キーフ ィ
ー ルドが一つも指定されていない場合は、 sort は行全体をグローバルオプシ
ョンに従って比較する。
最後に、全てのキーが等しい (あるいは順序オプションがまったく指定され な
か った) 場合には、 sort は最終手段として、行を LC_COLLATE ではなくマシ
ンの照合順序にしたがって 1 バイトずつ比較する。この最終手段の比較は -r
オプションに従う。 -s オプション (stable オプション) は、この最終手段比
較を無効にし、全てのフィールドの比較結果が同じだった行の順序を、入力 の
順 序のままにする。フィールドやグローバルオプションがまったく指定されな
かった場合は、 -s オプションは無視される。
出力順序オプション
以下のオプションは、 sort が行を出力する順序に影響する。これらはグロ ー
バ ルにも、あるいは特定のキーフィールドの一部としても指定できる。キーフ
ィールドが指定されなければ、グローバルオプションで行全体が比較される 。
キ ーフィールド指定がされた場合、順序オプションが特に指定されなかったフ
ィールドには、グローバルオプションが継承される。
-b 各行の比較の際に、行頭の空白を無視する。
-d 「電話帳」順でソートする。アルファベット、数字、空白以外のキャラ
クタをすべて無視してソートする。
-f ソートの際に、小文字を対応する大文字と同じに扱う。例えば ‘b’ は
‘B’ と同じとみなされる。
-g strtod(3) を用いて数値に変換した後、その数値順にソートする。これ
を用いると、浮動小数点の理工学的な記法 (‘1.0e-34’ や ‘10e100’ な
ど) を扱うことができる。このオプションは、他に手段がない場合に限
って用いること。これは -n よりずっと遅いし、有効桁数が多すぎると
、丸めたかたちで比較されてしまう。さらに、倍精度浮動小数点の範囲
で 扱えない数値は 0 であるかのように処理される。またオーバーフロ
ー・アンダーフロー・変換エラーは報告されない。
-i 印字可能でない文字を無視する。
-n 数値順に評価する。行先頭の文字列 (空白が前置されていても良い) を
数 値文字列として比較する。数値文字列は、先頭の - 符号 (なくても
良い)、 0 桁以上の数字、そして小数点と 0 桁以上の数字 (なくて も
良い) からなる。
sort は浮動小数点表記文字列を、あまり普通でない方法で比較する。
まず各文字を C の double 方に変換してからそれらの値を比較する の
で はなく、 2つの文字の基数点 (radix point) を揃えて、1 文字づつ
比較するのである。この方法の利点は速度である。実際この方法は、 2
つのそれぞれの文字列を double に変換してから比較するよりずっと速
い (あるいは integer 変換に比べてすらずっと速い)。また精度の問題
も生じない。多くのシステムでは、文字列を double に変換してから比
較する方法では、精度は 16 桁に制限されてしまう。
先頭の ‘+’ や指数表記は認識できない。このような文字列を数値的 に
比較するには -g を用いること。
-r, --reverse
比較の結果を逆順にする。より大きなキー値を持つ行が、より早く現わ
れるようになる。
-M 行頭の空白文字をすべて無視して最初に現われた 3 文字を、月の名 称
の 省略形とみなして ‘JAN’ < ‘FEB’ < ... < ‘DEC’ の順でソートする
。小文字は大文字と同じに扱われる。月の名称にない文字列は、より低
位であるとみなされる。
その他のオプション
+POS1[-POS2]
ソートフィールド指定の obosolete な古い形式。行の POS1 から POS2
の直前までのフィールドを指定する。 POS2 は含まない。 POS2 が省略
さ れたら行末まで。フィールドと文字位置はそれぞれ 0 から数えはじ
める。
-k POS1[,POS2]
-K POS1[,POS2] ソートフィールド指定の POSIX 形式。今後はこちらが
推 奨 さ れ る。行の POS1 から POS2 までのフィールドを指定する。
POS2 を含む。 POS2 が省略されたら行末まで。フィールドと文字位 置
はそれぞれ 0 から数えはじめる。
-o OUTFILE
出力先を標準出力から OUTFILE に変更する。 OUTFILE が入力ファイル
のどれかひとつだった場合、 sort はその入力ファイルを一時ファイル
にコピーしてから、ソートと OUTFILE への出力を行う。
-t SEPARATOR
各 行からソートキーを検索する際、文字 SEPARATOR をフィールドのセ
パレーターにする。デフォルトでは、フィールドは空白以外の文字と空
白文字の間の空文字列 (empty string) によって分離される。例えば入
力行として ‘ foo bar’ が与えられた場合、 sort はこの行をフィール
ド ‘ foo’ と ‘ bar’ に分離する。フィールドセパレーターは、その前
後のフィールドには含まれないものとされる。
-u デフォルトの動作と -m オプションの動作では、等しいとされた行のう
ちの最初のものだけを表示する。 -c オプションの動作では、連続した
行で等しいものがないかどうかをチェックする。
-z 入力における行の末尾が、
SORT(1) User Commands SORT(1)
NAME
sort - sort lines of text files
SYNOPSIS
sort [OPTION]... [FILE]...
sort [OPTION]... --files0-from=F
DESCRIPTION
Write sorted concatenation of all FILE(s) to standard output.
Mandatory arguments to long options are mandatory for short options
too. Ordering options:
-b, --ignore-leading-blanks
ignore leading blanks
-d, --dictionary-order
consider only blanks and alphanumeric characters
-f, --ignore-case
fold lower case to upper case characters
-g, --general-numeric-sort
compare according to general numerical value
-i, --ignore-nonprinting
consider only printable characters
-M, --month-sort
compare (unknown) < ‘JAN’ < ... < ‘DEC’
-h, --human-numeric-sort
compare human readable numbers (e.g., 2K 1G)
-n, --numeric-sort
compare according to string numerical value
-R, --random-sort
sort by random hash of keys
--random-source=FILE
get random bytes from FILE
-r, --reverse
reverse the result of comparisons
--sort=WORD
sort according to WORD: general-numeric -g, human-numeric -h,
month -M, numeric -n, random -R, version -V
-V, --version-sort
natural sort of (version) numbers within text
Other options:
--batch-size=NMERGE
merge at most NMERGE inputs at once; for more use temp files
-c, --check, --check=diagnose-first
check for sorted input; do not sort
-C, --check=quiet, --check=silent
like -c, but do not report first bad line
--compress-program=PROG
compress temporaries with PROG; decompress them with PROG -d
--files0-from=F
read input from the files specified by NUL-terminated names in
file F; If F is - then read names from standard input
-k, --key=POS1[,POS2]
start a key at POS1 (origin 1), end it at POS2 (default end of
line)
-m, --merge
merge already sorted files; do not sort
-o, --output=FILE
write result to FILE instead of standard output
-s, --stable
stabilize sort by disabling last-resort comparison
-S, --buffer-size=SIZE
use SIZE for main memory buffer
-t, --field-separator=SEP
use SEP instead of non-blank to blank transition
-T, --temporary-directory=DIR
use DIR for temporaries, not $TMPDIR or /tmp; multiple options
specify multiple directories
-u, --unique
with -c, check for strict ordering; without -c, output only the
first of an equal run
-z, --zero-terminated
end lines with 0 byte, not newline
--help display this help and exit
--version
output version information and exit
POS is F[.C][OPTS], where F is the field number and C the character
position in the field; both are origin 1. If neither -t nor -b is in
effect, characters in a field are counted from the beginning of the
preceding whitespace. OPTS is one or more single-letter ordering
options, which override global ordering options for that key. If no
key is given, use the entire line as the key.
SIZE may be followed by the following multiplicative suffixes: % 1% of
memory, b 1, K 1024 (default), and so on for M, G, T, P, E, Z, Y.
With no FILE, or when FILE is -, read standard input.
*** WARNING *** The locale specified by the environment affects sort
order. Set LC_ALL=C to get the traditional sort order that uses native
byte values.
AUTHOR
Written by Mike Haertel and Paul Eggert.
REPORTING BUGS
Report sort bugs to bug-coreutils@gnu.org
GNU coreutils home page:
Copyright(C) linux-cmd.com All Rights Reserved. Author Takayuki Yukawa