shell脚本 for循环实现文件和目录遍历
2015-09-08 09:54
676 查看
一个for循环实现一个目录下的文件和目录遍历,很实用
[root@localhost shell_order]# cat test27.sh #!/bin/bash #print the directory and file for file in /home/hustyangju/* do if [ -d "$file" ] then echo "$file is directory" elif [ -f "$file" ] then echo "$file is file" fi done [root@localhost shell_order]# ./test27.sh /home/hustyangju/array is directory /home/hustyangju/menuwindow-7.12 is directory /home/hustyangju/menuwindow-build-desktop is directory /home/hustyangju/shell_order is directory [root@localhost shell_order]#
相关文章推荐
- 通用shell
- Linux重新学习--shell script--函数
- ubuntu shell不兼容
- Genymotion的shell的命令
- linux bash环境变量简单总结
- 一个自动安装LNMP的简洁Shell脚本
- 使用dbms_scheduler调用shell脚本
- shell 文件遍历
- Vim编辑器,find命令及bash环境配置
- shell 批量替换文本中的字符串
- bash环境配置
- linux-bash环境变量
- vim&find&bash&
- Bash环境变量配置
- bash 环境变量
- find,vim,bash环境变量,文件权限
- linux--Xshell的使用
- linux--SSH Secure Shell Client
- linux shell中,单引号、 双引号,反引号(``),$()的区别
- linux shell中,单引号、 双引号,反引号(``),$()的区别