본문 바로가기

IT/unix_unixlike

uniq 중복항목 제거

반응형

uniq [-udc [-f fields] [-s chars] [input_file [output_file]]


input_file 생략시 <STDIN>

output_file 생략시 <STDOUT> 으로 출력


중복된 항목을 제거하여 출력해줌

-c 옵션 사용시 중복항목 카운트 해줌


ex)

사용할 데이터 파일

#test.dat

1

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15


$> uniq test.dat

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15


$> uniq -c test.dat

   2 1

   1 2

   1 3

   1 4

   1 5

   1 6

   1 7

   1 8

   1 9

   1 10

   1 11

   1 12

   1 13

   1 14

   1 15

반응형