得到所有目录与对目录下的文件进行操作的shell脚本
2011-11-17 16:09
656 查看
#! /bin/sh [ $# -ne 1 ] && { echo "usage: ./${0##*/} <path>" exit 0 } function notcompile () { ifelf=0 #echo $1 filesinsub=$(ls) #echo $filesinsub for eachfile in $filesinsub do if [ $ifelf -eq 1 ] then #echo "elf file exist" break fi elffileexist=$(file $eachfile | grep [Ee][lL][fF]) [ -n "$elffileexist" ] && ##if it is elf file, then run belows { #echo $(file $eachfile) ifelf=1 } done if [ $ifelf -eq 0 ] ##有.c文件的但是没有elf文件的 then #echo $1 ##已经可以输出了 #echo $(ls) #echo " " #echo " " #echo " " { ismakefiles=$(ls) for ismakefile in $ismakefiles do if [ "${ismakefile}" = "Makefile" ] then echo $1 echo $(ls) echo " " echo " " echo " " break fi done } fi if [ $ifelf -eq 1 ] then ifelf=0 fi } dirs=$(find $1 | sort) direxsit=0 for dir in $dirs do if [ -d $dir ] then { cd $dir files=$(ls) for file in $files do if [ $direxsit -eq 1 ] then direxsit=0 break fi if [ "${file#*.}" = "c" ] then #filemeta_c=$(file $file | grep "ASCII C program text") #if [ -n "$filemeta_c" ] ##c file exist #then direxsit=1 notcompile $dir #break fi done cd - > /dev/null } fi done
相关文章推荐
- 这是一个定时脚本,主要功能是遍历该文件夹下的所有文件并存储到数组,对数据中的文件进行操作,一个一个移动到指定的目录下,并删除原有文件
- shell脚本查找指定目录下所有子目录中的同名文件
- Shell脚本递归打印指定目录中所有目录文件
- shell脚本查找指定目录下所有子目录中的同名文件
- shell脚本批量修改目录下所有文件中的部分语句
- 小实验---采用iconv命令对目录文件进行递归式字符编码转换的shell脚本
- Linux学习6之shell筛选当前目录下文件并逐个对其进行操作
- shell脚本示例,复制名为dir1和dir2的目录下所有的文件到名为dir3的新目录
- Linux下使用Shell脚本删除一个目录下的所有子目录和文件
- shell脚本批量修改目录下所有文件中的部分语句
- shell 脚本,将/etc/目录下所有的软链接文件输出
- Python 和 bash shell脚本(python和shell, python中文件操作, python中目录操作)
- Shell脚本递归遍历目录所有文件
- shell小脚本实现上传目录中的所有文件到服务器
- 《使用shell位置变量进行目录文件的备份小脚本》
- Shell脚本:判断当前目录下所有的文件类型
- linux下设计一个Shell脚本:判断当前工作目录下所有的文件类型。
- 编写一个SHELL脚本,可以获得指定目录下的所有文件及文件夹的大小。输出的样式与 ls -lh 命令相同。
- Linux监控系统磁盘使用比例,当使用率达到指定比例,删除指定目录下的所有文件的shell脚本
- shell得到脚本文件所在目录