Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ls command

0 views
Skip to first unread message

e.group

unread,
Nov 4, 2003, 8:01:09 AM11/4/03
to
Hi all,
how can I extract ONLY the TOTAL NUMBER of files/subdirectorys from the ls
command?
thanks


Philippe Delsol

unread,
Nov 4, 2003, 8:16:45 AM11/4/03
to

"e.group" <erez...@hotmail.com> a écrit dans le message de news:
bo87uk$7fk$1...@news.att.net.il...

ls -al | wc -l

Philippe


Philippe Delsol

unread,
Nov 4, 2003, 8:20:00 AM11/4/03
to

"Philippe Delsol" <p.ns....@BLACKHOLEfree.fr> a écrit dans le message de
news: 3fa7a67b$0$255$626a...@news.free.fr...

Oops I forgot the recursive mode :

ls -alR | wc -l

Philippe


Oscar del Rio

unread,
Nov 4, 2003, 8:45:17 AM11/4/03
to

> how can I extract ONLY the TOTAL NUMBER of files/subdirectorys from the ls
> command?

not with 'ls' but should do:

find . | wc -l

Ken Gray

unread,
Nov 4, 2003, 10:39:14 AM11/4/03
to
In article <3fa7a73e$0$229$626a...@news.free.fr>,
"Philippe Delsol" <p.ns....@BLACKHOLEfree.fr> wrote:

The problem here is that you're going to be counting "." and "..", too.

To the OP: Why does it have to be with ls? find and/or du would be much
better for this purpose.

--
Ken

Real address krgray*at*verizon*dot*net

Thomas Schulz

unread,
Nov 4, 2003, 11:59:53 AM11/4/03
to
In article <CKPpb.3859$n6....@nwrddc03.gnilink.net>,

Ken Gray <see-sig-f...@nowhere.invalid> wrote:
>In article <3fa7a73e$0$229$626a...@news.free.fr>,
> "Philippe Delsol" <p.ns....@BLACKHOLEfree.fr> wrote:
>
>> "Philippe Delsol" <p.ns....@BLACKHOLEfree.fr> a écrit dans le message de
>> news: 3fa7a67b$0$255$626a...@news.free.fr...
>> >
>> > "e.group" <erez...@hotmail.com> a écrit dans le message de news:
>> > bo87uk$7fk$1...@news.att.net.il...
>> > > Hi all,
>> > > how can I extract ONLY the TOTAL NUMBER of files/subdirectorys from the
>> ls
>> > > command?
>> > > thanks
>> >
>> > ls -al | wc -l
>> >
>> > Philippe
>>
>> Oops I forgot the recursive mode :
>>
>> ls -alR | wc -l
>>
>> Philippe
>>
>
>The problem here is that you're going to be counting "." and "..", too.

You can fix that by using 'ls -AlR | wc -l'. But there are still blank
lines and lines giving totals. You can eliminate the totals by changing
the command to 'ls -A1R | wc -l' (the `l` changes to a one). The find
command given in another posting is better, but there is still one extra
line (the one listing just .).

>To the OP: Why does it have to be with ls? find and/or du would be much
>better for this purpose.
>
>--
>Ken
>
>Real address krgray*at*verizon*dot*net

--
Tom Schulz
sch...@adi.com

Oscar del Rio

unread,
Nov 4, 2003, 12:08:36 PM11/4/03
to
Thomas Schulz wrote:

> You can fix that by using 'ls -AlR | wc -l'. But there are still blank
> lines and lines giving totals. You can eliminate the totals by changing
> the command to 'ls -A1R | wc -l' (the `l` changes to a one). The find
> command given in another posting is better, but there is still one extra
> line (the one listing just .).

you are right, the following should skip the '.'

find . | tail +2 | wc -l

0 new messages