Sorting and columns
このページには最新のブラウザ(SharedArrayBuffer対応)が必要です。Chrome、Edge、Firefox、Safariを最新バージョンに更新してください。
English
Putting lines in order
sortarranges lines alphabetically (or, with-n, as numbers):
sort names.txt
sort -rreverses the order;sort -nis for lists of numbers.
English
Removing duplicates
uniqremoves neighbouring repeated lines. Because it only looks at neighbours, you usuallysortfirst:
sort names.txt | uniq
- Add
uniq -cto also count how many times each line appeared.

探索
sort, then uniq
uniq only sees neighbours — sort first, so the duplicates sit together.
English
Picking out columns
- Many files have columns separated by a character — a comma, a colon, a tab.
cutpulls out the columns you want.-dsets the delimiter,-fthe field:
cut -d : -f 1 people.txt
- That takes the first field of each
name:ageline — the names.
English
Common mistakes
sortis alphabetical;sort -nsorts numbers correctly.cutneeds the right delimiter with-d.
難易度 3/5 · 200 コイン + 今日初回達成時の小ボーナス
Get a tidy, de-duplicated list of names. Pipe sort 内へ uniq: sort names.txt | uniq.
難易度 3/5 · 200 コイン + 今日初回達成時の小ボーナス
people.txt has name:age on each line. Pull out just the names with cut -d : -f 1 people.txt.
難易度 3/5 · 200 コイン + 今日初回達成時の小ボーナス
How many times does each name appear in names.txt? Show each name once, with its 個体数 in front.
難易度 3/5 · 200 コイン + 今日初回達成時の小ボーナス
sizes.txt holds three file sizes. Sort them as numbers, largest first. (Plain sort -r puts 9 first: it compares text.)