Re: question about ls
On Thu, Sep 27, 2018 at 10:57:56AM -0400, Gene Heskett wrote:
> On Thursday 27 September 2018 08:31:27 Greg Wooledge wrote:
>
> > On Tue, Sep 25, 2018 at 10:27:03PM +0000, Long Wind wrote:
> > > can ls show number of items in a folder?Thanks!
> >
> > https://mywiki.wooledge.org/BashFAQ/004
>
> And finally, an "ls -l|wc -l" from the cli gives the answer to the
> question asked.
The question that was asked was a yes-or-no question. And the answer to
it is "no". However, some people will not perceive "no" to be a USEFUL
answer, so I provided an answer with much more depth.
"ls -l|wc -l" gives you the number of newlines contained in a stream
generated by printing the names of SOME of the files in the current
working directory.
It omits all of the filenames that begin with a period.
It includes all of the newlines that are contained within filenames, and
thus gives an inaccurate count if any of the filenames contain newlines.
Since this is a Debian mailing list, I won't attempt to go into the
behaviors of ls on other Unix-based systems. The two problems already
mentioned should suffice for this list.
Reply to: