目录名大小写转换

Posted by 4Aiur on 04/06/2010 in Shell |

使用find把目录名修改为大写——-

find . -type d | sort -r |\
while read name
do
   echo "mv $name ${name%/*}/echo ${name##*/} | tr '[:lower:]' '[:upper:]'"
   mv $name ${name%/*}/echo ${name##*/} | tr '[:lower:]' '[:upper:]'
done

使用递归方式把目录名修改为小写

#!/bin/bash
# set -x

tolower () {
   ls | while read name
   do
       if [ -d $name ] ; then
           new_name=echo $name | tr "[:upper:]" "[:lower:]"
           if [[ $name != $new_name ]] ; then
               mv $name $new_name
           fi
           cd $new_name
           tolower
       fi
   done
}
tolower

Tags:

Copyright © 2010-2024 4Aiur All rights reserved.
This site is using the Desk Mess Mirrored theme, v2.5, from BuyNowShop.com.