[SunRescue] finding a number of files in a dirB

Drew Schatt schatt at schatt.com
Tue Feb 22 14:57:46 CST 2000


	Sorry to reply to my own message, but assuming you know that there are no
dot-files with only one or two character names, you could do a 
"/bin/ls -d .??* *|wc -l".  
	I may be wrong, but the -d will make ls not
list the contents of directories, the .??* will list all dot files with
two or more characters following the dot, and the asterisk will list all
files/directories in the current directory. The pipe and full path name
will prevent aliases from making it multiple column output (remember, I
have my ls aliased, and you may as well, "which ls" will tell you).  I
think that this will accurately give you the number of files and
directories in the current folder, but not of any files in directories in
the current folder.  
	-Drew Schatt


On Tue, 22 Feb 2000, Drew Schatt wrote:

> As far as piping tabulated output through a pipe, ls -C will do so.  I've
> aliased ls on my machines to do ls -FCb.
> 	-Drew Schatt
> 
> On Tue, 22 Feb 2000, Kent Rankin wrote:
> 
> > > >       Mind you, I also noticed an individual(*grin*) that recommended a "ls |
> > > > wc -l", but that would potentially produce erroneous results due to the
> > > > tabulation of files when listed without the long format.  However,
> > > > credit should be given for not having introduced the ". & .." bug.
> > > 
> > >   Nope.  ls knows when its output is being redirected or piped...under
> > > those circumstances, it prints one filename per line.
> > > 
> > >   Try "ls | cat" to demonstrate this.
> > > 
> > >   ;-)
> > 
> > 	However, the "ls|wc -l" method still doesn't list *ALL* files(files
> > beginning with a period, in this example).  It does provide for a
> > line-by-line listing, though.  That's a step in the right direction. 
> > And since it doesn't list files starting with a period, it doesn't list
> > . or .. <end of sentence>







More information about the rescue mailing list