zoukankan      html  css  js  c++  java
  • shell for循环用法总结

    关于shell中的for循环用法很多,一直想总结一下,今天网上看到上一篇关于for循环用法的总
    结,感觉很全面,所以就转过来研究研究,嘿嘿…
    1、 for((i=1;i<=10;i++));do echo $(expr $i \* 4);done
    2、在shell中常用的是 for i in $(seq 10)
    3、for i in `ls`
    4、for i in ${arr[@]}
    5、for i in $* ; do
    6、for File in /proc/sys/net/ipv4/conf/*/accept_redirects; do
    7、for i in f1 f2 f3 ;do
    8、for i in *.txt
    9、for i in $(ls *.txt)
    for in语句与` `和$( )合用,利用` `或$( )的将多行合为一行的缺陷,实际是合为一个字符串
    数组
    ============ -_- ==============for num in $(seq 1 100)
    10、LIST=”rootfs usr data data2″
    for d in $LIST; do
    用for in语句自动对字符串按空格遍历的特性,对多个目录遍历
    11、for i in {1..10}
    12、for i in stringchar {1..10}
    13、awk ‘BEGIN{for(i=1; i<=10; i++) print i}’

    注意:AWK中的for循环写法和C语言一样的


    原文转载自:http://www.kuaiwenba.com/article/32.html

  • 相关阅读:
    java volatile关键字解惑
    Java 反射
    拷贝源实体类到目标实体类中
    Bean和Map之间的转换
    DateUtils时间的封装
    HttpClient的代码封装,便于直接调用
    HttpClient语法
    LinkedHashMap+ConcurrentHashMap+hashMap的区别
    1006 Tick and Tick
    Event Flow
  • 原文地址:https://www.cnblogs.com/catkins/p/5270642.html
Copyright © 2011-2022 走看看