需要脚本帮忙
发表于 : 2005-11-08 14:31
想要在一个目录下递归找到最末端的目录,就是没有子目录的那些。
没想清楚啊。那位帮忙。
没想清楚啊。那位帮忙。
代码: 全选
#!/bin/bash
#search most-end directory
function fnd0() {
for i in `ls $1`; do
#echo $i+"------------all"
if [ -d $i ]; then
fnd0 $i
fi
done
echo $i
return 0
}
find0 .
代码: 全选
#!/bin/bash
#search most-end directory
function fnd0() {
cd $1
# echo now\ in\ path\ --`pwd`
for i in `ls -A`; do
# echo 'search in '$1
if [ -d $i ]; then
# echo enter\ path\ --$i
# cd $i
fnd0 $i
# cd ..
fi
done
# echo found\ most-end\ direcotry\ is\ ------------------`pwd`
echo `pwd`
cd ..
# return 0
}
[! -d $1] && exit 1
exit 0
#end
代码: 全选
ls -RQ * |grep :$|sed 's/:$//'|sed 's/\ /\\\ /'