Sort_(UNIX)
[Wikipedia|▼Menu]
sort --help

sort(ソート)は、UNIXに標準的に存在するコマンド行プログラムの一種であり、入力の各行をソートされた順序で出力するものである。


カレント
ディレクトリにあるファイルリストをファイルサイズ順でソート
$ ls -s 。sort -n 96 Nov1.txt 128 _arch_backup.lst 128 _arch_backup.lst.tmp1708 NMON

名簿(電話帳)をアルファベット順にソート
$ cat phonebookSmith, Brett 555-4321Doe, John 555-1234Doe, Jane 555-3214Avery, Cory 555-4321Fogarty, Suzie 555-2314$ sort phonebookAvery, Cory 555-4321Doe, Jane 555-3214Doe, John 555-1234Fogarty, Suzie 555-2314Smith, Brett 555-4321

数値をキーとしたソートは -n オプションをつけることで可能となる。
$ du /bin/* 。sort -n 4 /bin/domainname 24 /bin/ls 102 /bin/sh 304 /bin/csh古いバージョンの sort では、+1 オプションを付けると、第二カラムのデータを使ってソートする(+2 では第三カラム)。これは現在ではサポートされていないが、その代替として -k オプションを同じ目的に使用できる。次の例は -n と "-k 2"(第二カラムを指定)を同時に指定している。$ cat zipcodeAdam 12345Bob 34567Joe 56789Sam 45678Wendy 23456$ sort -nk 2 zipcodeAdam 12345Wendy 23456Bob 34567Sam 45678Joe 56789

逆順でのソートには -r オプションを使う。
$ sort -nrk 2 zipcodeJoe 56789Sam 45678Bob 34567Wendy 23456Adam 12345
外部リンク

Manpage of SORT
JM Project

sort(1) man page(SunOS リファレンスマニュアル)

sort(1) man page(HP-UX リファレンス)
.mw-parser-output .asbox{position:relative;overflow:hidden}.mw-parser-output .asbox table{background:transparent}.mw-parser-output .asbox p{margin:0}.mw-parser-output .asbox p+p{margin-top:0.25em}.mw-parser-output .asbox{font-size:90%}.mw-parser-output .asbox-note{font-size:90%}.mw-parser-output .asbox .navbar{position:absolute;top:-0.90em;right:1em;display:none}

この項目は、ソフトウェアに関連した書きかけの項目です。この項目を加筆・訂正などしてくださる協力者を求めていますPJ:コンピュータ/P:コンピュータ)。
.mw-parser-output .hlist ul,.mw-parser-output .hlist ol{padding-left:0}.mw-parser-output .hlist li,.mw-parser-output .hlist dd,.mw-parser-output .hlist dt{margin-right:0;display:inline-block;white-space:nowrap}.mw-parser-output .hlist dt:after,.mw-parser-output .hlist dd:after,.mw-parser-output .hlist li:after{white-space:normal}.mw-parser-output .hlist li:after,.mw-parser-output .hlist dd:after{content:" ・\a0 ";font-weight:bold}.mw-parser-output .hlist dt:after{content:": "}.mw-parser-output .hlist-pipe dd:after,.mw-parser-output .hlist-pipe li:after{content:" |\a0 ";font-weight:normal}.mw-parser-output .hlist-hyphen dd:after,.mw-parser-output .hlist-hyphen li:after{content:" -\a0 ";font-weight:normal}.mw-parser-output .hlist-comma dd:after,.mw-parser-output .hlist-comma li:after{content:"、";font-weight:normal}.mw-parser-output .hlist-slash dd:after,.mw-parser-output .hlist-slash li:after{content:" /\a0 ";font-weight:normal}.mw-parser-output .hlist dd:last-child:after,.mw-parser-output .hlist dt:last-child:after,.mw-parser-output .hlist li:last-child:after{content:none}.mw-parser-output .hlist dd dd:first-child:before,.mw-parser-output .hlist dd dt:first-child:before,.mw-parser-output .hlist dd li:first-child:before,.mw-parser-output .hlist dt dd:first-child:before,.mw-parser-output .hlist dt dt:first-child:before,.mw-parser-output .hlist dt li:first-child:before,.mw-parser-output .hlist li dd:first-child:before,.mw-parser-output .hlist li dt:first-child:before,.mw-parser-output .hlist li li:first-child:before{content:" (";font-weight:normal}.mw-parser-output .hlist dd dd:last-child:after,.mw-parser-output .hlist dd dt:last-child:after,.mw-parser-output .hlist dd li:last-child:after,.mw-parser-output .hlist dt dd:last-child:after,.mw-parser-output .hlist dt dt:last-child:after,.mw-parser-output .hlist dt li:last-child:after,.mw-parser-output .hlist li dd:last-child:after,.mw-parser-output .hlist li dt:last-child:after,.mw-parser-output .hlist li li:last-child:after{content:")\a0 ";font-weight:normal}.mw-parser-output .hlist ol{counter-reset:listitem}.mw-parser-output .hlist ol>li{counter-increment:listitem}.mw-parser-output .hlist ol>li:before{content:" "counter(listitem)" ";white-space:nowrap}.mw-parser-output .hlist dd ol>li:first-child:before,.mw-parser-output .hlist dt ol>li:first-child:before,.mw-parser-output .hlist li ol>li:first-child:before{content:" ("counter(listitem)" "}.mw-parser-output .navbar{display:inline;font-size:75%;font-weight:normal}.mw-parser-output .navbar-collapse{float:left;text-align:left}.mw-parser-output .navbar-boxtext{word-spacing:0}.mw-parser-output .navbar ul{display:inline-block;white-space:nowrap;line-height:inherit}.mw-parser-output .navbar-brackets::before{margin-right:-0.125em;content:"[ "}.mw-parser-output .navbar-brackets::after{margin-left:-0.125em;content:" ]"}.mw-parser-output .navbar li{word-spacing:-0.125em}.mw-parser-output .navbar-mini abbr{font-variant:small-caps;border-bottom:none;text-decoration:none;cursor:inherit}.mw-parser-output .navbar-ct-full{font-size:114%;margin:0 7em}.mw-parser-output .navbar-ct-mini{font-size:114%;margin:0 4em}.mw-parser-output .infobox .navbar{font-size:88%}.mw-parser-output .navbox .navbar{display:block;font-size:88%}.mw-parser-output .navbox-title .navbar{float:left;text-align:left;margin-right:0.5em}

表示

編集










Unixコマンド
ファイルとファイルシステム管理

cat

chattr(英語版)

chmod

chown

chgrp

cksum

cmp

cp

dd

du

df(英語版)

file

fsck

fuser(英語版)

ln

ls

lsof

mkdir

mount

mv

pax

pwd

rm

rmdir

size

split

tee

touch

type(英語版)

umask(英語版)

プロセス管理

at

bg

chroot

cron

fg

kill

killall

nice

pgrep

pidof

pkill

ps

pstree(英語版)

reboot

shutdown

time

top

ユーザ管理/環境

clear

env

exit

finger

history(英語版)

id

logname(英語版)

mesg

passwd

su

sudo

uptime

talk

tput(英語版)

uname

w

wall

who

whoami

write

テキスト処理

awk

banner

basename

comm(英語版)

csplit(英語版)

cut

diff

dirname

ed

ex(英語版)

fmt

fold(英語版)

head

iconv

join(英語版)

less

m4

more

nkf

nl

paste(英語版)

patch

printf(英語版)

read(英語版)

sed

sort

spell(英語版)

strings

tail

tr

troff

uniq

vi

wc

xargs

yes

シェルビルトイン

alias

cd

echo

test(英語版)

unset

wait

通信

dig

host(英語版)

ifconfig

inetd


次ページ
記事の検索
おまかせリスト
▼オプションを表示
ブックマーク登録
mixiチェック!
Twitterに投稿
オプション/リンク一覧
話題のニュース
列車運行情報
暇つぶしWikipedia

Size:14 KB
出典: フリー百科事典『ウィキペディア(Wikipedia)
担当:undef