Daily Archives: 十月 24th, 2007

bash的for除了for $a in list用法外也可以初始值;条件;步进

例子
#!/bin/bash
sum=0
for i in $*
do
  j=0
  for((j=0;j<3;j++))
  do
    echo $j
  done
 
  echo $i
done

注意 要使用 初始值;条件;步进 格式 要使用(())而不是()

redhat需要在启动时运行命令可以添加到/etc/rc.d/rc.local

/etc/rc.d/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don’t
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
cmd1
cmd2