shell for

作者: allenhaozi | 来源:发表于2020-08-13 20:42 被阅读0次
第一类:数字性循环
-----------------------------
for1-1.sh

#!/bin/bash  
  
for((i=1;i<=10;i++));  
do   
echo $(expr $i \* 3 + 1);  
done  
-----------------------------
for1-2.sh

#!/bin/bash  
  
for i in $(seq 1 10)  
do   
echo $(expr $i \* 3 + 1);  
done   
-----------------------------
for1-3.sh

#!/bin/bash  
  
for i in {1..10}  
do  
echo $(expr $i \* 3 + 1);  
done  
-----------------------------
for1-4.sh

#!/bin/bash  
  
awk 'BEGIN{for(i=1; i<=10; i++) print i}'  
第二类:字符性循环
-----------------------------
for2-1.sh

#!/bin/bash  
  
for i in `ls`;  
do   
echo $i is file name\! ;  
done   
-----------------------------
for2-2.sh

#!/bin/bash  
  
for i in $* ;  
do  
echo $i is input chart\! ;  
done  
-----------------------------
for2-3.sh

#!/bin/bash  
  
for i in f1 f2 f3 ;  
do  
echo $i is appoint ;  
done  
-----------------------------
for2-4.sh

复制代码
#!/bin/bash  
  
list="rootfs usr data data2"  
for i in $list;  
do  
echo $i is appoint ;  
done  
复制代码
第三类:路径查找
-----------------------------
for3-1.sh

#!/bin/bash  
  
for file in /proc/*;  
do  
echo $file is file path \! ;  
done  
-----------------------------
for3-2.sh

#!/bin/bash  
  
for file in $(ls *.sh)  
do  
echo $file is file path \! ;  
done  

相关文章

  • Shell 学习

    shell 变量 shell 参数传递 shell 数组 shell 运算符 shell echo 命令 prin...

  • Shell 概述

    学习 Shell 主要包括的内容: Shell 脚本入门 Shell 变量 Shell 内置命令 Shell 运算...

  • Shell 教程

    Shell 变量 Shell 传递参数 Shell 数组 Shell 基本运算符 Shell echo 命令 Sh...

  • shell 第一天

    shell编程初识 1.1 shell编程初识 shell的定义 Shell 是命令解释器 Shell 也是...

  • shell 案例

    Shell编程一 Shell防范ARP攻击 Shell编程二 Shell防范DDos攻击 Shell编程三 ...

  • 【生物信息笔记】shell 脚本 (dry-2)

    shell 和 shell script(脚本)区别: shell 和 shell 脚本是两个不同概念,shell...

  • Linux Shell:基础知识和Shell变量

    摘要:Linux,Shell 整理Shell内容要点: Shell基础知识 Shell变量的类型 Shell变量赋...

  • Shell脚本语言一

    一、语法 格式 运行 Shell变量 Shell字符串 Shell数组 Shell注释 Shell传递参数 She...

  • 使用shell脚本

    使用方式 shell 变量 shell 字符串操作 shell 数组 shell 注释 shell 命令行参数 s...

  • vim学习 09——shell命令

    vim学习 09——shell命令 执行 shell 命令 :!shell命令 : 可以执行 shell 命令。 ...

网友评论

      本文标题:shell for

      本文链接:https://www.haomeiwen.com/subject/cjxacktx.html