ts="$(date '+%s')" ==》时间戳
sed -i "s/main.js?v=[0-9]*$/main.js?v=${ts}/g" ./xxx/index.html
#change-domain-entrypoint.sh echo '#!/bin/bash sed -i 's/\${DEV_DOMAIN}/\${NEW_DOMAIN}/g' /usr/share/nginx/html/*main*.js sed -i 's/\${DEV_DOMAIN}/\${NEW_DOMAIN}/g' /usr/share/nginx/html/sea-billing/*main*.js sed -i 's/main.js/main.js?v=123/g' /usr/share/nginx/html/sea-billing/index.html ts='"$(date '+%s')"' sed -i '\"s/main.js?v=[0-9]*/main.js?v=\${ts}/g\"' /usr/share/nginx/html/wms-billing/index.html ' > change-domain-entrypoint.sh
do_date=`date` ==> Thu Jun 3 14:33:58 CST 2020
do_date=`date +%F` ==> 2020-06-03
do_date=`date -d "-1 day" +%F` ==>2020-06-02
date +"%Y-%m-%d %H:%M:%S" 2020-06-03 14:20:25
eg:
1)在hadoop001的/home/hadoop/bin目录下创建脚本 [hadoop@hadoop001 bin]$ vim ods_log.sh 在脚本中编写如下内容 #!/bin/bash # 定义变量方便修改 APP=gmall hive=/soft/install/hive/bin/hive # 如果是输入的日期按照取输入日期;如果没输入日期取当前时间的前一天 if [ -n "$1" ] ;then do_date=$1 else do_date=`date -d "-1 day" +%F` fi echo "===日志日期为 $do_date===" sql=" load data inpath '/origin_data/gmall/log/topic_start/$do_date' into table "$APP".ods_start_log partition(dt='$do_date'); load data inpath '/origin_data/gmall/log/topic_event/$do_date' into table "$APP".ods_event_log partition(dt='$do_date'); " $hive -e "$sql" 说明1: [ -n 变量值 ] 判断变量的值,是否为空 -- 变量的值,非空,返回true -- 变量的值,为空,返回false 说明2: 查看date命令的使用,[hadoop@hadoop001 ~]$ date --help 2)增加脚本执行权限 [hadoop@hadoop001 bin]$ chmod 777 ods_log.sh 3)脚本使用 [hadoop@hadoop001 module]$ ods_log.sh 2019-02-11