Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 08 Dec 1999 08:44:50 -0500
From:      Jim Conner <jconner@enterit.com>
To:        FreeBSD Questions <freebsd-questions@FreeBSD.ORG>
Subject:   Re: hopefully three simple questions
Message-ID:  <4.2.0.58.19991208084058.009ac100@mail.enterit.com>
In-Reply-To: <19991208235053.A13173@kearneys.ca>
References:  <Pine.GSO.3.96.991208111339.2570A-100000@sol.cs.binghamton.edu> <Pine.GSO.3.96.991208111339.2570A-100000@sol.cs.binghamton.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
I sent these to Crist last night.  The shell script doesn't work :) (what 
can I say...I threw it together in 20 minutes)....however, the find will at 
least give a count of files in each directory based on where you run the 
find command from and store the output to a file of your choice. I don't 
think you will be able to answer this guy's questions with simple command 
on the command line.  Its going to require scripting (I think)

find . -type d -exec wc -l {} \; >files.out

#!/bin/ksh

counter=0
var=0
file=files.out
find . -type d -exec wc -l {} \; >$file

for loop in `cat $file | grep -E [0-9] | awk '{print $1}'`
do
counter=$((counter + 1))
var[$counter]=$loop
if [ $counter = 2 ]
then
if [ ${var[1]} -gt ${var[2]} ]
then
largest=${var[1]}
counter=1
elif [ ${var[2]} -gt ${var[1]} ]
then
largest=${var[2]}
counter=1
else
counter=1
fi
else
blah=0
fi
done
echo "The largest directory had $largest files: `grep $largest $file`"
rm $file

At 11:50 PM 12/8/99 -0800, Brent Kearney wrote:
>On Wed, Dec 08, 1999 at 11:19:01AM -0500, Zhihui Zhang wrote:
> >
> > I got three questions:
> >
> > (1) How to determine the deepest directory in a filesystem?
> >
> > (2) How to find the largest directory in a filesystem? I mean the one
> > with the maximum number of files in it.
>
>I'm not sure off hand how to go about this, perhaps some shell-wizard
>will answer your post.  For those who don't get the question, I think
>what it means is  1) How do you count how many subdirectories "deep" a
>filesystem goes, i.e., /mnt/blah/blah1/blah2/blah3/blah4/blah5, for the
>'blah' filesystem, there is a depth of 5., and 2) how do you count all
>of the files in a filesystem and report which directory has the most
>files in it?
>
>Zhihui, it is likely some combination of "find" and "du".
>
> >
> > (3) How to enforce automatic logout after specified amount of time?
> >
>
>This is set in /etc/login.conf, with the :idletime directive.  See man
>login.conf for details.
>
>-Brent
>
>
>To Unsubscribe: send mail to majordomo@FreeBSD.org
>with "unsubscribe freebsd-questions" in the body of the message


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Today's errors, in contrast:
Windows - "Invalid page fault in module kernel32.dll at 0032:A16F2935"
UNIX  - "segmentation fault - core dumped"
Humanous Beingsus - "OOPS, I've fallen and I can't get up"
-------------------------------
Jim Conner
NOTJames
jconner@enterit.com


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4.2.0.58.19991208084058.009ac100>