728x90
반응형
cat 명령어는 concatenate를 뜻합니다. 즉 파일을 하나로 합치는 주된 기능을 합니다.
cat명령어는 크게 2가지 기능을 합니다.
- 파일의 출력
- 파일 합치기
바로 사용법을 보도록 하겠습니다.
다음과 같은 파일이 존재한다고 가정을 해보겠습니다.
test1.file
Hello
Hello
Hello
test2.file
World
World
World
cat filename
- cat명령어 뒤에 파일 이름을 명시해 파일 안의 내용을 출력합니다.
jjh@jjh-desktop:~$ cat test1
Hello
Hello
Hello
jjh@jjh-desktop:~$
- 파일 이름을 여러 개 명시하면 파일의 내용을 합쳐 출력합니다.
jjh@jjh-desktop:~$ cat test1 test2
Hello
Hello
Hello
World
World
World
jjh@jjh-desktop:~$ cat test2 test1
World
World
World
Hello
Hello
Hello
jjh@jjh-desktop:~$
cat -n filename
- -n 옵션으로 줄 번호 옵션을 사용할 수 있습니다.
jjh@jjh-desktop:~$ cat -n test2 test1
1 World
2 World
3 World
4 Hello
5 Hello
6 Hello
jjh@jjh-desktop:~$
cat filename filename > newfilename
- cat 뒤에 합칠 파일들을 명시해주고 '>' 키워드로 합쳐 만들어질 파일 이름을 명시해줄 수 있습니다.
jjh@jjh-desktop:~$ cat test2 test1 > test3
jjh@jjh-desktop:~$ ls
test1 test2 test3
jjh@jjh-desktop:~$
728x90
반응형
'Linux > 명령어(CentOS)' 카테고리의 다른 글
가장 많이 검색하는 리눅스 명령어와 사용 방법 (간략) (0) | 2023.12.07 |
---|---|
[CentOS] useradd 사용자 생성의 모든 것 !!!! (0) | 2022.03.08 |
[CentOS] sudo 명령어 권한 부여 (0) | 2022.02.25 |
[CentOS] 리눅스 서비스 명령어 systemctl (0) | 2022.02.22 |