posted @ 2020-05-18 13:40
随笔分类 - shell
摘要:1.test 测试范围:整数,字符串,文件 表达式结果为真,则test的返回值为0,否则为非0。 表达式结果为真,则变量$?的值为0,否则为非0 (一)字符串 判断是否相等: test $str1 == $str2 ;echo $? test $str1 != $str2;echo $? 判断是否有
阅读全文
posted @ 2019-11-03 19:06
摘要:#! /bin/bash read -t 30 -p "please input your name:" name echo $name read -t 30 -p "please input your name and age:" name age echo $name echo $age read -t 30 -sp "please input you password:" pwd echo
阅读全文
posted @ 2019-11-03 15:06
摘要:(1)获取参数:从shell文件传来参数,调用:$1,$2,$3 load_date=$1 clearn_date=`date -d"$2 day ago $load_date" +%Y-%m-%d` local_path=$3 (2)执行HIVE: hive -e 后面是直接用双引号拼接hives
阅读全文
posted @ 2019-11-03 09:34
摘要:(1)今天 date -d "now" +"%Y-%m-%d" (2)昨天 date -d "yesterday" +"%Y-%m-%d" date -d "1 day ago" +"%Y-%m-%d" (3)具体日期的前几天 date -d "n days ago $具体日期" +%Y-%m-%d
阅读全文
posted @ 2019-11-03 09:16
摘要:(一)定义规则 不能以数字开头 等号两侧不可以有空格 变量名称一般大写 --列出所有的变量 set (二)变量分类 1.用户自定义变量:作用域只在当前的shell 2.系统/环境变量:作用域为当前的shell及其子shell,保存和系统环境相关的变量 $HOME $PATH $PWD, 3.位置参数
阅读全文
posted @ 2019-10-31 19:36
摘要:1)脚本以 #!/bin/bash 开头 2)脚本需要有可执行权限 1.绝对路径 和 相对路径 新起shell环境 2.bash 和 sh 新起shell环境 bash first.sh sh first.sh 3.source 和 . --当前环境 source first.sh . first.
阅读全文
posted @ 2019-10-31 17:28
浙公网安备 33010602011771号