shell
lfwer
这个作者很懒,什么都没留下…
展开
-
shell数据遍历
#/bin/sh 定义数据ary=('item0' 'item1' 'item2')v='item0' white1=(1 2)white2=(11 22) #判断ary数组中是否包含vif echo "${ary[@]}" | grep -w "${v}"then echo "yes"else echo "no&原创 2018-11-12 10:58:23 · 1001 阅读 · 0 评论 -
shell 字符串转数组
test.sh脚本如下:apps="${1}"#按“T”分隔arr=(${apps//T/ })for app in ${arr[@]}do apps2="${app}" #按“,”分隔 arr2=(${apps2//,/ }) for app2 in ${arr2[@]} do echo "${app2}" donedo...原创 2018-07-06 13:59:01 · 943 阅读 · 0 评论 -
shell脚本导出mysql数据库数据到文件
/usr/bin/mysql -uroot -p******** -h******** statistics -A --default-character-set=utf8 -N -e "SELECT trim(',' from t2.white_user_group_ids),t.scene_id,t.exposure_pv FROM v_scene_statistics t LEFT JOI...原创 2018-07-02 18:16:25 · 3802 阅读 · 0 评论 -
shell脚本统计文件行数并取出10%
#!/bin/shc=0c=`sed -n '$=' test.txt`let c=$c/10echo $c原创 2018-06-25 19:02:18 · 245 阅读 · 0 评论 -
shell 常用命令
查找1.txt中出现2.txt里的文字的结果输出到final.txtawk 'NR==FNR{a[$1];next}{s=substr($0,5);if((s in a)){print substr($0,1,11)}}' 1.txt 2.txt>final.txt取两个文件的交集grep -F -f a.txt b.txt | sort | uniq ...原创 2018-06-22 15:29:40 · 86 阅读 · 0 评论 -
shell脚本循环遍历目录文件并通过curl进行上传
#!/bin/sh #待上传文件目录upload_dirName="/home/operationPhone/upload/"#上传完毕后备份目录complete_dirName="/home/operationPhone/complete/"#日志目录log_dirName=“/var/log/”#当前日期currentDate=`date +%Y-%m-%...原创 2018-06-21 16:35:00 · 1644 阅读 · 0 评论 -
编写shell脚本通过ftp下载文件并进行合并去重操作
#!/bin/bash today_date=`date +%Y%m%d`now=`date +'%Y-%m-%d %H:%M:%S'` echo "===================================${now}脚本开始执行=====================================" >> /home/shell/log/dat...原创 2018-06-21 14:38:12 · 864 阅读 · 0 评论 -
编写shell脚本通过ftp下载文件并进行合并去重操作
#!/bin/bash today_date=`date +%Y%m%d`now=`date +'%Y-%m-%d %H:%M:%S'` echo "===================================${now}脚本开始执行=====================================" >> /home/shell/log/data...原创 2019-01-17 17:53:34 · 245 阅读 · 0 评论 -
shell脚本循环遍历目录文件并通过curl进行上传
#!/bin/sh #待上传文件目录upload_dirName="/home/operationPhone/upload/"#上传完毕后备份目录complete_dirName="/home/operationPhone/complete/"#日志目录log_dirName=“/var/log/”#当前日期currentDate=`date +%Y-%m-%d...原创 2019-01-17 17:53:40 · 1907 阅读 · 0 评论 -
shell 常用命令
查找1.txt中出现2.txt里的文字的结果输出到final.txtawk ‘NR==FNR{a[$1];next}{s=substr($0,5);if((s in a)){print substr($0,1,11)}}’ 1.txt 2.txt>final.txt取两个文件的交集grep -F -f a.txt b.txt | sort | uniq删除一周前的文件find /h...转载 2019-01-17 17:54:09 · 723 阅读 · 0 评论 -
shell脚本统计文件行数并取出10%
#!/bin/shc=0c=sed -n '$=' test.txtlet c=$c/10echo $c原创 2019-01-17 17:54:33 · 491 阅读 · 0 评论 -
shell脚本导出mysql数据库数据到文件
/usr/bin/mysql -uroot -p******** -h******** table_name -A --default-character-set=utf8 -N -e “SELECT 1 FROM dual” > /tmp/date +%Y%m%d -d -1day.txt-A 取消检查-N 不输出列头-e sql语句...原创 2018-11-12 14:18:52 · 3821 阅读 · 0 评论 -
shell 字符串转数组
test.sh脚本如下:apps="${1}" #按“T”分隔 arr=(${apps//T/ }) for app in ${arr[@]} do apps2="${app}" #按“,”分隔 arr2=(${apps2//,/ }) for app2 in ${arr2[@]} do echo "${app2}" ..原创 2018-11-12 10:57:46 · 7304 阅读 · 0 评论 -
shell数据遍历
#/bin/sh 定义数据ary=('item0' 'item1' 'item2')v='item0' white1=(1 2)white2=(11 22) #判断ary数组中是否包含vif echo "${ary[@]}" | grep -w "${v}"then echo "yes"else echo "no"fi ...原创 2018-07-13 18:57:31 · 1123 阅读 · 0 评论