두개이상의 파일을 한꺼번에 삭제하기
작성자 정보
- 관리자 작성
- 작성일
컨텐츠 정보
- 3,370 조회
- 0 추천
- 목록
본문
두개이상의 파일을 한꺼번에 삭제하기
파일을 삭제할 수 있는 rm명령어에서 삭제대상파일을 지정할 때에 대상파일의 패턴을 지정할 수 있습니다.
이번에는 둘이상의 파일을 한번에 삭제하는 예를 보도록 하겠습니다.
[root@su250 html]# ls -l 합계 24 -rw-r--r-- 1 root root 68 2008-12-25 00:41 file.htm -rwxr-xr-x 1 root root 53 2008-12-25 00:41 file1.htm -rw-r--r-- 1 root root 60 2008-12-25 00:41 file2.htm -rw-r--r-- 1 root root 53 2008-12-25 00:41 file3.htm -rwxr-xr-x 1 root root 62 2008-12-23 19:17 imsi.sh drwxr-xr-x 5 root root 4096 2008-12-24 22:41 su -rw-r--r-- 1 root root 0 2008-12-23 17:47 text01 -rw-r--r-- 1 root root 0 2008-12-23 17:47 text02 -rw-r--r-- 1 root root 0 2008-12-23 17:47 text03 -rw-r--r-- 1 root root 0 2008-12-23 17:47 text04 -rw-r--r-- 1 root root 0 2008-12-23 17:47 text05 [root@su250 html]# [root@su250 html]# rm file* rm: remove 일반 파일 `file.htm'? y rm: remove 일반 파일 `file1.htm'? y rm: remove 일반 파일 `file2.htm'? y rm: remove 일반 파일 `file3.htm'? y [root@su250 html]# [root@su250 html]# ls -l 합계 8 -rwxr-xr-x 1 root root 62 2008-12-23 19:17 imsi.sh drwxr-xr-x 5 root root 4096 2008-12-24 22:41 su -rw-r--r-- 1 root root 0 2008-12-23 17:47 text01 -rw-r--r-- 1 root root 0 2008-12-23 17:47 text02 -rw-r--r-- 1 root root 0 2008-12-23 17:47 text03 -rw-r--r-- 1 root root 0 2008-12-23 17:47 text04 -rw-r--r-- 1 root root 0 2008-12-23 17:47 text05 [root@su250 html]# |
위의 예를 보면 "rm file*" 처럼 file이라는 문자열로 시작하는 모든 파일을 삭제하였습니다.
이번 예에서는 -f 옵션을 사용하지 않았기 때문에 파일 하나하나 모두 삭제확인을 한 후에 삭제가 되었습니다.
다음에는 -f옵션을 사용하여 삭제 확인과정 없이 둘이상의 파일을 한번에 삭제하는 예를 보겠습니다.
[root@su250 html]# ls -l 합계 8 -rwxr-xr-x 1 root root 62 2008-12-23 19:17 imsi.sh drwxr-xr-x 5 root root 4096 2008-12-24 22:41 su -rw-r--r-- 1 root root 0 2008-12-23 17:47 text01 -rw-r--r-- 1 root root 0 2008-12-23 17:47 text02 -rw-r--r-- 1 root root 0 2008-12-23 17:47 text03 -rw-r--r-- 1 root root 0 2008-12-23 17:47 text04 -rw-r--r-- 1 root root 0 2008-12-23 17:47 text05 [root@su250 html]# [root@su250 html]# rm -f text* [root@su250 html]# [root@su250 html]# ls -l 합계 8 -rwxr-xr-x 1 root root 62 2008-12-23 19:17 imsi.sh drwxr-xr-x 5 root root 4096 2008-12-24 22:41 su [root@su250 html]# |
위의 예는 "rm -f
text*"라고 하여 "text"라는 문자열로 시작하는 파일을
모두 삭제 확인과정 없이 바로 삭제 되었습니다.
관련자료
-
이전
-
다음