게시물 1,375건
   
파일 일괄변경 명령어 (rename)
글쓴이 : 최고관리자 날짜 : 2011-01-19 (수) 17:15 조회 : 21335
글주소 :
                                
mv 명령어를 통해서 파일명 변경이 가능하지만 일정한 패턴에 복수에 파일을 수정하기에는 상당히 번거롭고 귀찮은 일이다.
리눅스에서는 rename 이라는 명령어로 파일명 일괄 변경이 가능하다
 
예를 들어 나같은 경우는 htb 서버에 디바이스 명칭을 변경해주려고 한다.
이럴때 사용한다면....아래처럼
[root@chonnom htb]# ls -al
drwxr-xr-x   2 root root   4096  1월 19 17:05 .
drwxr-x---  10 root root   4096  1월 19 17:05 ..
-rw-r--r--   1 root root     45  1월 19 17:05 eth2
-rw-r--r--   1 root root     61  1월 19 17:05 eth2-10.CL_a
-rw-r--r--   1 root root     65  1월 19 17:05 eth2-11.CL_b
-rw-r--r--   1 root root     64  1월 19 17:05 eth2-12.CL_c
-rw-r--r--   1 root root     62  1월 19 17:05 eth2-14.SH_d
-rw-r--r--   1 root root     61  1월 19 17:05 eth2-15.SH_e
-rw-r--r--   1 root root     62  1월 19 17:05 eth2-16.CL_f
-rw-r--r--   1 root root     63  1월 19 17:05 eth2-17.CL_g
-rw-r--r--   1 root root     62  1월 19 17:05 eth2-18.CL_h
 
[root@chonnom htb]# rename eth2 eth3 eth2*
 ==> eth2 가 포함된 파일명을 eth3으로 변경하는데 eth2* 파일 모두를 변경
 
[root@chonnom htb]# ls -al
drwxr-xr-x   2 root root   4096  1월 19 17:05 .
drwxr-x---  10 root root   4096  1월 19 17:05 ..
-rw-r--r--   1 root root     45  1월 19 17:05 eth3
-rw-r--r--   1 root root     61  1월 19 17:05 eth3-10.CL_a
-rw-r--r--   1 root root     65  1월 19 17:05 eth3-11.CL_b
-rw-r--r--   1 root root     64  1월 19 17:05 eth3-12.CL_c
-rw-r--r--   1 root root     62  1월 19 17:05 eth3-14.SH_d
-rw-r--r--   1 root root     61  1월 19 17:05 eth3-15.SH_e
-rw-r--r--   1 root root     62  1월 19 17:05 eth3-16.CL_f
-rw-r--r--   1 root root     63  1월 19 17:05 eth3-17.CL_g
-rw-r--r--   1 root root     62  1월 19 17:05 eth3-18.CL_h
# rename [변경할 문자] [변경될 문자] 변경할 파일들
 
 
man 페이지
 RENAME(1)           Linux Programmer's Manual           RENAME(1)
NAME
      rename - Rename files
SYNOPSIS
      rename from to file...
DEscRIPTION
      rename will rename the specified files by replacing the first occurrence of from in
      their name by to.
      For example, given the files foo1, ..., foo9, foo10, ..., foo278, the commands
             rename foo foo0 foo?
             rename foo foo0 foo??
      will turn them into foo001, ..., foo009, foo010, ..., foo278.
      And
             rename .htm .html *.htm
      will fix the extension of your html files.
SEE ALSO
      mv(1)

이름 패스워드
비밀글 (체크하면 글쓴이만 내용을 확인할 수 있습니다.)
왼쪽의 글자를 입력하세요.
   

 



 
사이트명 : 모지리네 | 대표 : 이경현 | 개인커뮤니티 : 랭키닷컴 운영체제(OS) | 경기도 성남시 분당구 | 전자우편 : mojily골뱅이chonnom.com Copyright ⓒ www.chonnom.com www.kyunghyun.net www.mojily.net. All rights reserved.