2007. 11. 3. 21:33 Unix/Shell
대문자 파일명을 소문자로
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
UNIX GURU UNIVERSE
UNIX HOT TIP
Unix Tip 2390 - July 18, 2006
http://www.ugu.com/sui/ugu/show?tip.today
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
UNIX GURU UNIVERSE
UNIX HOT TIP
Unix Tip 2390 - July 18, 2006
http://www.ugu.com/sui/ugu
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
대문자 파일명을 소문자로
이 스크립트는 현재 디렉토리에 있는 모든 파일명을 대문자에서 소문자로 변경하는데
사용할 수 있다.
나는 이 스크립트를 윈도우 시스템에서 유닉스 기반의 웹서버에 업로드하려고 할 때
파일 이름이 원하지 않게 대문자로 변경되었을 경우 사용한다.
###########################
for uppercase in `ls`
do
for lowercase in `ls $uppercase|tr [A-Z] [a-z]`
do
mv $uppercase $lowercase 2>/dev/null
done
done
############################
譯者 註)
1번줄 : ls의 결과를 "uppercase"라는 변수로 받아 for문
2번줄 : 主반복문 실행
3번줄 : "uppercase" 변수를 tr을 통해 대문자를 소문자로 변환후
"lowercase" 변수에 저장
4번줄 : 하위반복문 실행
5번줄 : "uppercase" 변수 내용을 "lowercase" 변수 내용으로 변환
원문의 스크립트가 잘못되어있다. 주의요망
6번줄 : 하위반복문 종료
7번줄 : 主반복문 종료
@@@@@@@@@@@@@@@@@@@@[ 원문 ]@@@@@@@@@@@@@@@@@@@@
FILNAMES UPPER TO LOWER
This script can be used to
renames all the file in
current directory with
UPPERCASE letters to lowercase.
I uses it because some time when
I try to upload some files from
a Windows system to a unix based
web server, the files somehow gets
converted to UPPERCASES, which is
undesirable.
###########################
for uppercase in `ls`
do
for lowercase in `ls $uppercase|tr [A-Z] [a-z]`
do
mv $lowercase $uppercase 2>/dev/null
done
done
############################
This script can be used to
renames all the file in
current directory with
UPPERCASE letters to lowercase.
I uses it because some time when
I try to upload some files from
a Windows system to a unix based
web server, the files somehow gets
converted to UPPERCASES, which is
undesirable.
###########################
for uppercase in `ls`
do
for lowercase in `ls $uppercase|tr [A-Z] [a-z]`
do
mv $lowercase $uppercase 2>/dev/null
done
done
############################
반응형