1. 程式人生 > >Shell中大小寫互換

Shell中大小寫互換

今天需要寫個shell,建立hive的分割槽表,因為配置中的表名都是大寫,但是HDFS的路徑對大小寫敏感,需要將所有的表名轉換為小寫,那麼就需要用到tr來處理了:

table=`echo $line | tr '[:upper:]' '[:lower:]'`  #大寫轉小寫
table=`echo $line | tr '[:lower:]' '[:upper:]'`  #小寫轉大寫
#!/bin/bash
startdate=$1
enddate=$2
cat hivetablelist | while read line
do
table=`echo $line | tr '[:upper:]' '[:lower:]'`  #大寫轉小寫
sh create.sh $startdate $enddate $table
echo $table
done