[code]#!/bin/bash
dir=-1
file=0
for i in `find $1 -maxdepth 10`
do
if [ -d $i ]
then
let "dir=$dir + 1"
fi
if [ -f $i ]
then
let "file=$file + 1"
fi
done
echo "there are $dir dirs"
echo "there are $file files"
let "total=$dir + $file"
if [ $total -gt 10 ]
then
for i in `find $1 -maxdepth 10`
do
if [ -f $i ]
then
user=$( ls -l $i|awk '{print $3}' )
echo "$user : $i"
fi
done
fi
[/code]上面目录子目录层次设为10,如果仅仅想查询一层目录,可以设为1
上面保存为test.sh
执行一下命令即可
bash test.sh /opt
tim211314 于 2011-10-28 15:25:09发表:
[code]#!/bin/bash
dir=-1
file=0
for i in `find $1 -maxdepth 10`
do
if [ -d $i ]
then
let "dir=$dir + 1"
fi
if [ -f $i ]
then
let "file=$file + 1"
fi
done
echo "there are $dir dirs"
echo "there are $file files"
let "total=$dir + $file"
if [ $total -gt 10 ]
then
for i in `find $1 -maxdepth 10`
do
if [ -f $i ]
then
user=$( ls -l $i|awk '{print $3}' )
echo "$user : $i"
fi
done
fi
[/code]上面目录子目录层次设为10,如果仅仅想查询一层目录,可以设为1
上面保存为test.sh
执行一下命令即可
bash test.sh /opt
flyhan 于 2011-10-28 17:15:22发表:
偶也等待,也想学习下shell
wokanhaoziji 于 2011-10-28 15:47:51发表:
大家知道一点说一点 这样也可以的:0wmjh(1