[Linux] 파일 출력, 정렬, 중복 행 제거
2023. 3. 15. 16:21ㆍCS/Linux
- head(tail) -n 3 [파일이름]
- 지정한 파일 앞, 뒤로 n행 출력
yoonho@DESKTOP-QJCBDQD:~/workspace$ cat test_head.txt
a
b
c
yoonho@DESKTOP-QJCBDQD:~/workspace$ head -n 2 test_head.txt
a
b
yoonho@DESKTOP-QJCBDQD:~/workspace$ tail -n 2 test_head.txt
b
c
- sort [파일이름]
- 파일 행 단위 정렬
- -r : 내림차순
- -n : 숫자 오름차순
yoonho@DESKTOP-QJCBDQD:~/workspace$ cat test_sort.txt
c
a
b
d
yoonho@DESKTOP-QJCBDQD:~/workspace$ sort test_sort.txt
a
b
c
d
yoonho@DESKTOP-QJCBDQD:~/workspace$ cat test_sort_n.txt
2
3
4
1
yoonho@DESKTOP-QJCBDQD:~/workspace$ sort -n test_sort_n.txt
1
2
3
4
- uinq [파일이름]
- 중복된 내용의 행이 연속으로 있는 경우 중복 제거
- [명령어] [파일이름] | uniq : 해당 명령어 실행 전 중복 제거
yoonho@DESKTOP-QJCBDQD:~/workspace$ cat test_uniq.txt
11
22
33
33
44
yoonho@DESKTOP-QJCBDQD:~/workspace$ cat test_uniq.txt | uniq
11
22
33
44
'CS > Linux' 카테고리의 다른 글
| [Linux] 파일의 특정 패턴 검색, 추출 (0) | 2023.03.21 |
|---|---|
| [Linux] clear, history, find, export, alias (0) | 2023.03.14 |
| [Linux] bash, sudo, 파일(폴더) 처리 (0) | 2023.03.13 |
| [Linux] VI 편집기 쉘 커맨드 (0) | 2023.03.08 |
| [Linux] 폴더 생성 & 디렉토리 디렉토리 확인 및 이동 (0) | 2023.03.07 |