티스토리 뷰

 

 

[Linux mv와 rename 명령어]



1. mv 명령


# 파일명 변경 또는 파일 이동

# mv [options] source dest

# mv [options] source... directory


$ mv access.log.2013032901_10.230.15.230  access.log.2013032901


# 파일명이 유일하면 *도 가능

$ mv access.log.2013032901_*  access.log.2013032901



### 배치파일로 여러 명령 실행가능!

 

#!/bin/sh

mv access.log.2013032901_*  access.log.2013032901

mv access.log.2013032902_*  access.log.2013032902

mv access.log.2013032903_*  access.log.2013032903

 

또는

#!/bin/sh

echo "`mv access.log.2013032901_*  access.log.2013032901`"

echo "`mv access.log.2013032902_*  access.log.2013032902`"

echo "`mv access.log.2013032903_*  access.log.2013032903`"



2. rename 명령


# 보통 파일 한개의 이름을 바꾸려면 mv 명령을 쓴다.

$ mv test1 testrename1.txt



# 한꺼번에 많은 양의 파일의 이름을 바꾸려면 rename사용한다.

# rename [변경전 파일명] [변경후 파일명] [대상파일]

# rename 명령어는 파일패턴문자(?, *)를 인식하기 때문에 여러 개의 파일을 동시에 처리가능하다


# .htm 확장자를 .html로 일괄 수정하기

$ rename .htm .html *.htm



# .php3 확장자를 .php로 일괄 수정하기

$ rename .php3 .php *.php3



<참고>

http://linuxis.tistory.com/145

http://cafe.daum.net/comerang/M7Ja/48?docid=14wsvM7Ja4820090904171534



댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함