を使用して既に実行しましたbash
が、 を使用してこのサブディレクトリの名前またはパスを取得するにはどうすればよいですかtcsh
。後で、このサブディレクトリ内のすべてのファイルの合計サイズをカウントする必要があります。助けてください。
例えば:
someDirectory
--firstDirectory
----file11.txt
----file12.txt
----file13.txt
--secondDirectory
----file21.txt
--thirdDirectory
----file31.txt
----file32 .txt
----file33.txt
----file34.txt
----file35.txt
その結果、サードディレクトリへのパスを取得したいのですが、ほとんどのファイルが含まれているためです。
アップデート
Bash ソリューション
#!/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