shell 编程——for in 循环
来源:互联网 发布:数字验证码识别算法 编辑:程序博客网 时间:2024/05/01 23:44
for 无$变量 in 字符串
do
done
一简单的字符串 枚举遍历法,利用for in格式对字符串按空格切份的功能
SERVICES="80
for
#!/bin/sh
for i in a b c
do
echo "i is $i"
done
i is a
i is b
i is c
#!/bin/bash
for i in *.h ;
do
cat ${i}.h
done
[macg@vm test]$ ./tip.sh
cat: *.h.h: No such file or directory
$i代表的是整个路径,而不是*.h里的.h前面的部分
#!/bin/bash
for i in *.h
do
cat $i
done
[macg@vm test]$ echo hahaha >>1.h
[macg@vm test]$ echo ha >>2.h
[macg@vm test]$ ./tip.sh
hahaha
ha
for i in /etc/profile.d/*.sh
done
/etc/profile.d/alias.sh, /etc/profile.d/default.sh
test()
{
}
$*是字符串:以"参数1 参数2 ... " 形式保存所有参数
$i是变量i的应用表示
[macg@machome ~]$ sh test.sh p1 p2 p3 p4
i is p1
i is p2
i is p3
i is p4
[root@vm testtip]# ls
aaa.txt
bbb.txt
[root@vm testtip]# cat go.sh
for i in *.txt
do
mv "$i" "$i.bak"
done
[root@vm testtip]# sh go.sh
[root@vm testtip]# ls
aaa.txt.bak
for i in $(ls *.txt)
do
echo $i
done
[macg@machome ~]$ sh test
111-tmp.txt
111.txt
22.txt
33.txt
LIST="rootfs usr data data2"
for d in $LIST; do
done
- shell 编程——for in 循环
- shell 编程——for in 循环
- shell 编程——for in 循环
- shell 编程——for in 循环
- shell编程 for in 循环
- shell编程 for in 循环
- shell编程 for in 循环
- shell ——for in 循环
- 脚本乐园 shell编程for in 循环
- 脚本乐园 shell编程for in 循环
- shell编程 for in 循环 抓取index
- Shell编程—for循环总结【转】
- shell for循环编程
- shell编程--for循环
- linux shell编程for循环
- Shell 编程6(循环语句for)
- Linux shell编程之for循环
- shell编程-流程控制-for循环
- 爱心桃
- android 自定义ImageView实现图片手势滑动,多点触摸放大缩小效果
- 我听到慈善和文明的脚步声在中国更响了
- 31-异步获取数据
- Android DiskLruCache完全解析,硬盘缓存的最佳方案
- shell 编程——for in 循环
- 预防MySQL宕机:合理设置MySQL最大用户连接数
- windows下使用SCons编译tolua++
- 一箭穿心
- poj2533Longest Ordered Subsequence LIS(优化)
- 如果将synthesize省略,语义特性声明为assign retain copy时,自己实现setter和getter方法
- Linux 文件和目录操作的相关函数
- 五角星
- HDU 1541 Stars (树状数组)