文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>find使用 和 一个递归

find使用 和 一个递归

时间:2005-12-20  来源:ruiqingzheng

find使用 和 一个递归

#file: ~/t.sh
#usage: ./t.sh /etc
#!/bin/bash

lsDir()
{
 if [ $# -lt 1 ] ;then
  echo "arguments error"
  exit 1
 fi
 local path=$1
 for var in `ls "$path"`
 do
  local subpath="${path}/${var}"
  if [ -d "${subpath}" ];then
   echo "${subpath} [directory]"
   lsDir $subpath
  elif [ -f "${subpath}" ];then
   echo "${subpath}  [FILE]"
  fi
 done
}

lsDir $1


用find替代ls
find /etc -type d | xargs ls  #结果是察看找到的目录里面的内容
find /etc -type d | xargs ls -d
find /etc -type f | xargs echo > /tmp/file   #把 /etc下面的文件名放到file
find /etc -type f -name tmp.txt | xargs cat > /tmp/a #文件内容cat到a
find /etc -path "/etc/setup" -prune -o print
find /etc -type d -exec ls -d {} ;

find / -size 0c -exec ls {} ;  #这样会把所有大小为0字节的目录里面文件都列出来
find / -size 0c -exec ls -d {} ;
find / -size 0c -exec echo {} ;

find / -size 0c | xargs echo

-perm mode:文件许可正好符合mode  #不是很明白
-perm +mode:文件许可部分符合mode
-perm -mode: 文件许可完全符合mode

相关阅读 更多 +
排行榜 更多 +
奥丘树海之下小米服手游下载

奥丘树海之下小米服手游下载

角色扮演 下载
网络天才国际服手游下载

网络天才国际服手游下载

休闲益智 下载
御剑红尘手游官方版下载

御剑红尘手游官方版下载

角色扮演 下载