Reference: http://saiyaren.iteye.com/blog/1943207 1. Shell 读取文件和写文件 for line in $(<top30000.url.utf-8.http_server_front_hphp.txt); do tmp_port=8080; for((i=0;i<=7;i++));do echo ${line/192\.168\.12\.63/192\.168\.12\.63:$tmp_port} >>top3000
在编写shell脚本中,经常要处理一些输入参数,在使用过程中发现getopts更加方便,能够很好的处理用户输入的参数和参数值. getopts用于处理用户输入参数,举例说明使用方法: while getopts :a:b:cdefg opt; do case $opts in a) do sth; ...... cde) do another; esac done 几个重要变量: OPTIND:getopts使用OPTIND作为索引,
变量 shell并不区分变量的类型,或者说变量都是弱类型的,本质上都是字符串,但是如果变量值中只含有数字,shell还是支持对其进行算术运算 赋值 常见的赋值操作符有=(在其前后没有空白符)和let # let 赋值 a=123 let b=a+1 echo "value of a is $b" #value of a is 124 # = 赋值 a="hello world" echo "${a}" #hello world # in 赋值 f