源地址:http://www.cnblogs.com/barrychiao/archive/2012/10/22/2733210.html对于有的表格比较模糊,请单击鼠标右键,查看图像,能看到比较清晰的表格shell变量详解1 shell变量基础shell 变量是一种很“弱”的变量,默认情况下,一个变量保存一个串,shell不关心这个串是什么含义。所以若要进行数学运算,必须使用一些命令例如let、
项目背景:在局域网内,取某一台主机当作服务器,并且开启ftp服务,提供apr、apr-utils、pcre、httpd软件下载运行环境:redhat 6.4#!/bin/bash#自动化安装apacheyum list &>/dev/nullif [[ "$?" != "0" ]];then if [ -e /dev/sr0 ];then 
实验环境:VMware12 、 redhat 6.4 、支持中文#!/bin/bash#shell自动搭建DHCP服务rpm -q dhcp &>/dev/nullif [ $? -eq 0 ];then echo "dhcp服务已经搭建" else echo "dhcp服务还未搭建,马上开始搭建"
#!/bin/bash#while truedo dialog --title "modify" --nocancel --menu "choose one" 20 40 8 1 "create user" 2 "create didrectory" 3 "create file" 4 "modify directory and fiel" 5 "modify
#!/bin/bash#user=`whoami`if [ "$user" == "root" ];then echo "root is super user"else echo "$user is a normal user"fi
exp文件的编写#!/usr/bin/expect set timeout 10set fname [lindex $argv 0]set ip [lindex $argv 1]set dname [lindex $argv 2]#spawn scp $fname root@$ip:$dnamespawn ssh root@$ipexpect { &n
#!/bin/bash#匹配http://样式urlread -p "input the file path:" fileegrep -o "\<http://[a-z0-9\.]+\.[a-z]{2,3}\>" $file |sort|uniq -c|sort -rn >url注释:[a-z0-9\.]+ ----这样做的意义是为了匹配二级域名及多级&n
#!/bin/bash#过滤A类、B类、C类地址#过滤A类地址 -o 只显示符合的A类地址[1-126]read -p "input the file absolute path:" fileegrep -o "([0-9]|[1-9][0-9]|1[01][0-9]|12[0-6])\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\>" $file |sort -n
工作环境:Red Hat Enterprise Linux Server release 6.5 (Santiago) 、bash &nb
工作环境:Red Hat Enterprise Linux Server release 6.5 (Santiago) 、 bash#!/bin/bash#name=testpassword=123123IP=10.0.0.254lftp -u $name,$password $IP <<EOFmkdir zenglinjuncd zenglinjunput $1 $2lsEOF注释:
工作环境:Red Hat Enterprise Linux Server release 6.5 (Santiago) 、 bash#!/bin/bash#for i in $@do mkdir $i if [ $? -eq 0 ];then  
工作环境:Red Hat Enterprise Linux Server release 6.5 (Santiago) 、 bash#!/bin/bash#hour=`date +%H`min=`date +%M`end_hour=$(echo "17-$hour"|bc)end_min=$(echo "30-$min"|bc )if [ $end_hour -lt 0 ];then &
工作环境:Red Hat Enterprise Linux Server release 6.5 (Santiago) 、 bash#!/bin/bash#xingming=(`cat name.txt`)echo "共有${#xingming[@]}位成员:${xingming[@]}"echo -n "让我们一起倒数:"#sleep 1#echo -n "3 "#sle
工作环境:Red Hat Enterprise Linux Server release 6.5 (Santiago) 、 bash#!/bin/bash#nmap -n -sP 10.0.0.1-254|grep "10.0.0"|awk '{print $5}' >ceshi.txta=(`cat ceshi.txt |tr "\n" " "`)echo "${a[@]}"注释: -n&
工作环境:Red Hat Enterprise Linux Server release 6.5 (Santiago)、bash#!/bin/bash#xm=(`cat name.txt`)for i in ${xm[@]}do xb=$(($RANDOM%${#xm[@]})) echo -n "${#xm[@]} 
工作环境:Red Hat Enterprise Linux Server release 6.5 (Santiago) 、 bash#!/bin/bash#注意find命令出错,但是放入wc命令后,该命令的运行结果还是对的#for i in `echo $PATH|tr ":" "\n"`#do# end=$(find $i -type f 2>
工作环境:Red Hat Enterprise Linux Server release 6.5 (Santiago) 、 bash#!/bin/bash##cat xferlog |awk '{print $7,$8}'|sort -n|head -100 >ssh.txtcat xferlog |awk '{print $7,$8}'|sort -t. -k3,4 -n &nb
工作环境:Red Hat Enterprise Linux Server release 6.5 (Santiago) 、 bash#!/bin/bash#[ "$1" == "" ] && echo "语法错误"[[ "$1" =~ ^[0-9] ]] && echo "数字开头"[[ "$1" =~ ^[a-zA-Z] ]] && echo "字
工作环境:Red Hat Enterprise Linux Server release 6.5 (Santiago) 、 bash#!/bin/bash#for i in `seq -w 1 10`do echo "user$i添加成功" read -s -p "input passwd:" pass
select与case的集合
九九乘法表
if的用法
while读取文件
RANDOM生成随机数
工作环境:Red Hat Enterprise Linux Server release 6.5 (Santiago) 、bash #!/bin/bash#until [[ $choice == "end" ]]doread -p "input name:" nameuntil ! [ -z $name ]do echo ""  
Copyright © 2005-2024 51CTO.COM 版权所有 京ICP证060544号