[SunRescue] finding a number of files in a dirB

Drew Schatt schatt at schatt.com
Tue Feb 22 14:43:19 CST 2000


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.
> > 
> >   ;-)
> 
> 	And this, right here, is exactly why I always include a disclaimer. 
> Regardless of whether I'm speaking or writing.  *LMAO*
> 
> 	I hadn't thought of ls' awareness of I/O redirection.  I was familiar
> of it(in fact, is anyone familiar with a way to prevent it from doing
> that?), as I have always been frustrated by my lack of ability to pipe
> tabulated ls'.  *sigh*
> 
> 	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>
> 
> 	Thus, I come to that point of "two out of three ain't bad".  That
> doesn't mean that it does the job.  For listing all non-hidden files, it
> works wonders.  But for listing all files in a directory, well... you
> know.  *grin*
> 
> 	Thanks for pointing that out, though.  I had forgotten about the
> redirection awareness.
> 
> 
> 								-Kent Rankin
> 
> _______________________________________________
> Rescue maillist  -  Rescue at sunhelp.org
> http://www.sunhelp.org/mailman/listinfo/rescue
> 







More information about the rescue mailing list