shell
qq_ceiling
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
find xargs 查找包文本内容的文件
find . -type f -print0 | xargs -0 grep -i 'text'原创 2025-04-08 15:16:44 · 103 阅读 · 0 评论 -
sed相关
1、vi 替换换行符 :%s#\n#\t#g2、在行首或行尾添加内容 sed 's/^/&hellow/g' file.txt sed 's/$/&hellow/g' file.txt 3、先查找#开头的行再删除里面包含log的行 sed -i '/^#/{/log/d}' file.txt4、正向预查 (?=local) 匹配loc...原创 2018-06-20 16:32:14 · 305 阅读 · 0 评论 -
常见的随机数据生成方法
1、echo $RANDOM2、openssl rand -base64 83、date +%s%N4、head /dev/urandom |cksum5、cat /proc/sys/kernel/random/uuid |md5sum6、(expect)mkpasswd -s 0|md5sum7、openssl rand -hex 108、 openssl rand -base64 20...原创 2017-07-31 21:51:55 · 1021 阅读 · 0 评论 -
调用系统成功失败函数
#!/bin/bash. /etc/init.d/functionsif [[ "$(whoami)" = "root" ]]; then action "root user" /bin/trueelse action "no root" /bin/falsefi原创 2017-09-12 22:18:07 · 382 阅读 · 0 评论 -
常见变量计算
1. a=$((3+5)) 或 ((a=3+5))2. echo $[2+3]运算符 ++ -- + - ! ~ * ** / % = == != > & ^ | && || = +=3. let i=1+44. expr 2 + 2 5. expr length "hello" 计算字条长度6. seq -s + 100|bc echo 3.3+3.4|bc原创 2017-07-31 21:51:20 · 421 阅读 · 0 评论 -
awk 求和、最大、最小、平均值
1、求和cat data|awk '{sum+=$1} END {print "Sum = ", sum}'2、求平均cat data|awk '{sum+=$1} END {print "Average = ", sum/NR}'3、求最大值cat data|awk 'BEGIN {max = 0} {if ($1>max) max=$1 fi} END {print "Ma原创 2017-06-29 21:12:52 · 441 阅读 · 0 评论 -
expect无信任远程批量执行命令
#!/bin/bash#remote command#date 20160821username=rootpasswd=123456usage(){ echo "Usage:sh `basename $0` -f [hostlist] -c [command]" exit 1}while getopts ":f:c:" o原创 2017-02-21 22:04:29 · 1064 阅读 · 0 评论 -
mysql 数据库备份脚本
#!/bin/bashbakdir=/backup_mysql/bakdir2=/backup_mysql/mysqluser=rootpass=date=`date "+%Y%m%d%H%M"`database=`mysql -u"$user" -e "show databases" |sed 1d|grep -v schema`if [ ! -d原创 2017-03-17 09:31:52 · 442 阅读 · 0 评论 -
shell数字转换成IP
#!/bin/baship=$1#10to2i=`echo "obase=2;$ip" |bc`#split 2n=$[${#i}-24]d=${i:0-8:8}c=${i:0-16:8}b=${i:0-24:8}a=${i:0:$n}#2to10((a1=2#"$a"))((b1=2#"$b"))((c1=2#"$c"))((d1=2#"$d"))#r原创 2017-03-09 22:49:32 · 641 阅读 · 0 评论 -
对shell脚本进行加密
脚本里有时候会有一些重要的信息,如用户名密码等,如果不想让别人看到可以使用gzexe进行加密1、新建脚本#vi echo.sh#!/bin/bashecho "123456"2、增加执行权限#chmod +x echo.sh3、对脚本进行加密gzexe echo.sh4、加密后会生成一个echo.sh~源文件,echo.sh是加密后的文件#lsec原创 2017-03-09 22:04:15 · 2654 阅读 · 0 评论 -
expect无信任远程批量拷贝文件
#!/bin/bash# Remote Copy file# date 20160821username=rootpasswd=123456usage(){ echo "Usage:sh `basename $0` -f [hostlist] Local_file Remote_file" exit 1}while get原创 2017-02-21 22:10:09 · 782 阅读 · 0 评论
分享