今天需要写个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