【12-shell脚本编程】
kakane
这个作者很懒,什么都没留下…
展开
-
【shell编程】 nginx 服务的启动脚本
#!/bin/bash## nginx This shell script takes care of starting and stopping# standalone nginx.# config: /usr/local/nginx/conf/nginx.conf# Source function library.. /etc/rc.d/ini原创 2012-03-29 23:54:29 · 1603 阅读 · 0 评论 -
【shell编程】 awk 常见练习题整理
【1】 打印UID在30-40之间的用户名 awk -F : '{ for(i=30;i【2】打印第5-10行,输出用户名和行号 awk -F : '{if(NR>=5&&NR【3】打印奇数行 awk -F : '{if(NR%2!=0) print $0}' /etc/passwd | head原创 2012-03-19 00:19:52 · 1428 阅读 · 0 评论 -
【shell编程】基础知识
【1】 shell 是命令解释器 系统默认的shell是 bash 查看shell的分类 1】 cat /etc/shells 2】 chsh -l 3】 ls /bin/*sh 【2】 用命令查看环境变量 env原创 2012-03-11 22:56:27 · 570 阅读 · 0 评论 -
【shell编程】 数据自动备份脚本的编写
【1】 要求 1】 每天产生一个bin_log 2】 每周产生一份mysqldump的完整备份 3】 下一周将原有的bin_log删除 4】 下一周将原有的mysqldump备份删除【2】 编写备份脚本 vim backup_everyday.sh #/bin/bash原创 2012-03-22 22:50:03 · 1017 阅读 · 0 评论 -
【shell脚本】检测局域网内存活主机
#!/bin/bash#测试局域网中的存活主机for i in {1..254}do ping -c 1 192.168.1.$i &>/dev/null && echo 192.168.1.$i is alive &done原创 2012-03-15 00:08:47 · 870 阅读 · 0 评论 -
【redhat5.5】linux中的awk总结
1 打印UID在30-40之间的用户名 awk -F : '{ for(i=30;i2 打印第5-10行,输出用户名和行号 awk -F : '{if(NR>=5&&NR3 打印奇数行 awk -F : '{if(NR%2!=0) print $0}' /etc/passwd | head -54 打印偶数行 awk -F : '{if(NR%2==0) pri原创 2012-03-16 01:00:26 · 681 阅读 · 0 评论 -
【shell编程】sed 常见练习题总结
【1】删除文件每行的第一个字符。[root@seker ~]# sed 's/\(.\)\(.*\)/\2/' /etc/passwd | tail -3[root@uplooking ~]# sed 's/.//' /etc/passwd | tail -3 【2】删除文件每行的第二个字符。[root@seker ~]# sed 's/\(.\)\(.\)\(.*\)/\1\3/原创 2012-03-19 00:33:53 · 4995 阅读 · 1 评论 -
[shell] 检测局域网内存活主机
#!/bin/bash#测试局域网中的存活主机for i in {1..254}do ping -c 1 192.168.1.$i &>/dev/null && echo 192.168.1.$i is alive &done原创 2012-12-07 10:22:09 · 2317 阅读 · 0 评论 -
[shell] 上传key后用expect 实现大量机器ssh首次登录
1> ssh-expect.exp#!/usr/bin/expectset i [lindex $argv 0]set timeout 30spawn ssh root@slave$iexpect "(yes/no)?"send "yes\r"expect -re "\]($|#)"send "exit\r"interact2 do_ssh.sh#!/bin/b原创 2012-12-12 15:52:02 · 2917 阅读 · 0 评论