随笔分类 -  shell

摘要:1.系统函数 2.自定义函数 阅读全文

posted @ 2020-05-18 13:40 happygril3 阅读(91) 评论(0) 推荐(0)

摘要: 阅读全文

posted @ 2020-05-18 12:03 happygril3 阅读(86) 评论(0) 推荐(0)

摘要: 阅读全文

posted @ 2020-05-18 11:57 happygril3 阅读(124) 评论(0) 推荐(0)

摘要: 阅读全文

posted @ 2020-05-18 11:45 happygril3 阅读(98) 评论(0) 推荐(0)

摘要:使用变量时加 "$var" 阅读全文

posted @ 2020-05-18 10:09 happygril3 阅读(137) 评论(0) 推荐(0)

摘要:1.test 测试范围:整数,字符串,文件 表达式结果为真,则test的返回值为0,否则为非0。 表达式结果为真,则变量$?的值为0,否则为非0 (一)字符串 判断是否相等: test $str1 == $str2 ;echo $? test $str1 != $str2;echo $? 判断是否有 阅读全文

posted @ 2019-11-03 19:06 happygril3 阅读(134) 评论(0) 推荐(0)

摘要: 阅读全文

posted @ 2019-11-03 15:21 happygril3 阅读(88) 评论(0) 推荐(0)

摘要:#! /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 happygril3 阅读(139) 评论(0) 推荐(0)

摘要:(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 happygril3 阅读(134) 评论(0) 推荐(0)

摘要:(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 happygril3 阅读(85) 评论(0) 推荐(0)

摘要:(一)定义规则 不能以数字开头 等号两侧不可以有空格 变量名称一般大写 --列出所有的变量 set (二)变量分类 1.用户自定义变量:作用域只在当前的shell 2.系统/环境变量:作用域为当前的shell及其子shell,保存和系统环境相关的变量 $HOME $PATH $PWD, 3.位置参数 阅读全文

posted @ 2019-10-31 19:36 happygril3 阅读(135) 评论(0) 推荐(0)

摘要: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 happygril3 阅读(214) 评论(0) 推荐(0)

导航