Press "Enter" to skip to content

Linux shell之seq用法

$ seq 1000   #起始默认是 1,间隔默认也是1
$ seq 2 1000  #间隔默认是1
$ seq 1 3 10    #从1到10,间隔为3,结果是:1 4 7 10
#!/bin/bash
for i in `seq 1 10`
do
  echo eth$i does not have a 1000 card!!
done

Linux循环遍历文件写法:

for file in `ls /etc/sysconfig/network-scripts/ifcfg-*`
do
  echo $file
done

以下是本人写的某脚本:

#!/bin/bash
for file in `ls /etc/sysconfig/network-scripts/ifcfg-*`
do
  i=${file##*-}
  #echo now checking $i
  if [ `ifconfig $i | grep 10000base | wc -l` -ge 1 ]; then
    id = `cat /proc/interrupts | grep $i | grep -v $i- | awk '{print $1}'`
    echo 'ff' > /proc/irq/${id%:*}/smp_affinity
    echo $i optimized.
  fi
done

参考文章:linux shell 动态生成 数组系列 seq使用技巧

Leave a Reply

Your email address will not be published. Required fields are marked *