본문 바로가기
개발/Linux

[Mac/Linux] cat / date 명령어 - date >> date > 차이점

by yo.na 2022. 1. 17.
터미널 갖고놀기!
xshell 에서 공부 한 Linux 명령어 Mac 터미널에서 실행해보기

 

1. cat 명령어로 파일 생성, 내용입력, 출력

$ cat >hello.prac  // 현재 폴더에 hello.prac이라는 파일 생성 및 내용 저장
echo helloworld!
:q
^C                 // command+C 로 탈출

$ ls               
copy		folder1		hello		hello.prac

$ cat hello.prac   // 내용 출력
echo helloworld!
:q

 

2. 내용 복사 후 출력

$ cat < hello.prac > hello.copy    // hello.prac 내용 hello.copy 파일에 복사

$ more hello.prac hello.copy       // hello.prac, hello.copy 파일 내용 출력
echo helloworld!
:q
...skipping...
echo helloworld!
:q

 

3.  date 명령어로 현재 시간 출력. 

     -  date >> 와 date > 의 차이점

$ date >> hello.prac                  // 현재시간 hello.prac 에 추가

$ cat hello.prac
echo helloworld!
:q
2022년 1월 17일 월요일 15시 34분 09초 KST


$ date > hello.copy                   // 현재시간 hello.copy 안의 내용 삭제 후 추가

$ cat hello.copy
2022년 1월 17일 월요일 15시 34분 28초 KST