0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Linucレベル1勉強メモ #30

Posted at

# 第三章 GNUとUnixのコマンド

練習問題3.5
テキストファイルsample.oldの中に重複する行があれば1行にまとめて出力し、sample.newとして保存しようとしています。下線部に当てはまるコマンドを記述してください。

$ sort sample.old | _______ > sample.new

(解答)uniq

(解説)重複する行を1行にまとめたい場合はuniqコマンドを使います。ただし、あらかじめソートしておく必要があるので、sortコマンドと組み合わせるのが一般的です。

uniqコマンド
入力されてテキストストリームの中で長封している行を調べて、重複している行は1行にまとめて出力します。入力するテキストストリームはソートしておく必要があるので、多くの場合、sortコマンドとパイプで組み合わせて使います。

書式 uniq [オプション] [入力ファイル[出力ファイル]]

uniqコマンドの主なオプション

  1. -d, --repeated
    重複している行のみ出力する
  2. -u, --unique
    重複していない行のみ出力する
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?