我已经使用bash
完成了它,但是如何使用tcsh
获取名称或路径到此子目录。后来我需要计算这个子目录中所有文件的总大小,请帮助我。如何查找某些目录的子目录,其中包含大部分文件
例如:
someDirectory
--firstDirectory
---- file11.txt
---- file12.txt
---- file13.txt
--secondDirectory
---- file21.txt
--thirdDirectory
---- file31.txt
---- file32.txt
---- file33.txt
---- file34.txt
---- file35.txt
而作为结果,我想路径thirdDirectory,因为它有最文件。
更新
击的解决方案
#!/bin/bash -f
declare -i maxcount=0
declare -i count
declare maxdirectory
find someFolder -type d | while read DIR;
do let count=`(ls $DIR | wc -w)`
if(($count > $maxcount)); then
let maxcount=count
maxdirectory="$DIR"
fi
done
更新
TCSH的解决方案
cd $1
foreach x(*)
if(-d $x) then
set count = `(ls $x -1 | wc -l)`
if($count > $maxcount) then
set directory = $x
set maxcount = $count
endif
endif
end
你怎么会在bash做呢? 'du'是一个很好的命令... – 2013-03-04 15:55:33
Fredrik,在我计算文件的总大小之前,我需要获取文件夹中的数据,但我不能用'tcsh'来完成,我必须使用所有这些'tcsh' – Procurares 2013-03-04 16:09:36