how sort recursively by maximum fileze and counts files type?
Posted
by
user599395
on Stack Overflow
See other posts from Stack Overflow
or by user599395
Published on 2011-02-02T03:52:56Z
Indexed on
2011/02/02
15:25 UTC
Read the original article
Hit count: 233
bash
Hello!
I'm beginner in bash programming. I want to display head -n $1 results of sorting files by size in /etc/*. The problem is that at final search, I must know how many directories and files has processed.
I compose following code:
#!/bash/bin
let countF=0;
let countD=0;
for file in $(du -sk /etc/* |sort +0n | head $1); do
if [ -f "file" ] then
echo $file;
let countF=countF+1;
else if [ -d "file" ] then
let countD=countD+1;
fi
done
echo $countF
echo $countD
I have errors at execution. How use find with du, because I must search recursively?
© Stack Overflow or respective owner