본문 바로가기

linux

리눅스 기본 명령어3[diff,find,tar,ln,sed,cp,mv]

728x90
반응형

16. diff 명령어

" 파일간의 차이점을 찾아서 알려주는 명령어"

 

:

$diff emp.txt emp7.txt


[orcl:~]$ diff emp.txt emp2.txt


15a16

>  7934 MILLER               CLERK                    7782 82/01/11       1300          0         10




17. find 명령어

"검색하고자 하는 파일을 찾을 사용하는 명령어"

:

$find   디렉토리  -name   '파일명'   -print

                                   

   검색할 디렉토리          검색할 파일명


[orcl:~]$ find /home/oracle -name 'emp.txt' -print

/home/oracle/test100/emp.txt

/home/oracle/test200/emp.txt

/home/oracle/emp.txt

/home/oracle/backup/emp.txt

/home/oracle/test002/test77/emp.txt

/home/oracle/bbb/emp.txt




 18. tar명령어

   : 파일을 압축하고 압축 해제하는 명령어

      1. 압축할

      tar cvf 압축파일명 압축파일대상

 

      2. 압축 해제할 때

      tar xvf 압축파일명 압축해제할 위치

 

      3. 옵션

         1) -c : compress, 여러 개의 파일을 하나로 보여라

         2) -v : view, 압축되는 과정을 보여달라

         3) -f : file, 생성되는 파일명을 지정

         4) -x : extract, 묶여있는 파일을 풀어줘라

         5) -C : 압축 풀릴 위치 지정





문제. /home/test002/test77 이라는 디렉토리에 있는 emp*.txt 파일들을 all.tar 이라는 이름으로 압축하시오


[orcl:test002]$ tar cvf all.tar ./test77/*txt

./test77/emp.txt

./test77/emp1.txt

./test77/emp2.txt

./test77/emp400.txt

./test77/winter.txt

./test77/winter1.txt

./test77/winter2.txt

./test77/winter3.txt





문제. 그자리에 압축을 해제하시오


[orcl:test002]$ tar -xvf  all.tar

./test77/emp.txt

./test77/emp1.txt

./test77/emp2.txt

./test77/emp400.txt

./test77/winter.txt

./test77/winter1.txt

./test77/winter2.txt

./test77/winter3.txt





19. ln(link) 명령어

 

"윈도우의 바로가기 기능과 유사함"

 

"내가 자주 열어봐야하는 파일이 있다변 바로가기를 생성해 놓으면

편하게 열어볼 있다"

 

예제:

$ ln -s "링크를 파일위치와 파일명" "바로가기이름"

$ mkdir -p ./test22/test23/test24/test25/test26/test27

 

하위 디렉토리 test27 가려면??

 

$ cd ./test22/test23/test24/test25/test26/test27

 

확인

[orcl:test27]$ pwd

/home/oracle/test22/test23/test24/test25/test26/test27

 



20. sed 명령어

"grep 명령어는 파일의 특정 내용을 검색하는 기능을 갖는다면

sed 명령어 검색뿐만 아니라 내용을 변경 있다"

 

예제:

$ sed 's/KING/yyy/' emp.txt

 

설명: emp.txt 출력할 KING yyy 변경해서 출력한다.


[orcl:~]$ sed 's/KING/yyy/' emp2.txt

7839 yyy                 PRESIDENT                   0 81/11/17       5000          0         10



BUT

cat emp2.txt 해서 보면

안바뀌었다화면에 출력해서 보는 창에서만 바뀐거다






  21. cp 명령어

"파일을 복사하는 명령어"

예제:

$cp 파일명 복사할 파일명

$ cp 위치/파일명 위치/복사할 파일명

$ cp emp.txt emp400.txt

$ cat emp400.txt  # 파일 보는 명령어




 

22. mv 명령어

"파일의 이름을 바꾸거나 파일을 다른 디렉토리로 이동하는 명령어"

예제:

$ mv 기존파일명 새로운파일명

$ mv emp400.txt emp500.txt

 

$ mv emp.txt ./backup/

$ ls emp.txt





문제. backup 디렉토리에 있는 emp2.txt 를 홈디렉토리로 옮기시오


[orcl:~]$ mv ./backup/emp2.txt .


./  ===>  /home/oracle 을 대신한다.

.   ===> 현재위치




728x90
반응형