Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
03-01-2005, 11:44 AM
|
#1
|
Member
Registered: Dec 2004
Distribution: Fedora Core 5
Posts: 64
Rep:
|
Directory Summary Command
Is there a command that will provide the number of files in a given directory?
|
|
|
03-01-2005, 11:49 AM
|
#2
|
Member
Registered: Feb 2005
Location: South Carolina
Distribution: Ubuntu 6.06 LTS
Posts: 83
Rep:
|
"ls" maybe?..i dont think that gives number of files just lists all the files
|
|
|
03-01-2005, 11:50 AM
|
#3
|
Member
Registered: Dec 2004
Distribution: Fedora Core 5
Posts: 64
Original Poster
Rep:
|
I don't I can use ls for this. I've tried the different types ls but they don't work.
|
|
|
03-01-2005, 12:04 PM
|
#4
|
Member
Registered: Aug 2004
Location: Davis, California
Distribution: Gentoo, always Gentoo.
Posts: 159
Rep:
|
ls -l | wc -l
Actually that'll give you 1 more than the total number of files since it includes the 'total' line at the top in the count.
|
|
|
03-01-2005, 12:13 PM
|
#5
|
LQ Newbie
Registered: Feb 2005
Location: Denmark
Distribution: Debian Lenny
Posts: 7
Rep:
|
Quote:
Originally posted by dsegel
ls -l | wc -l
Actually that'll give you 1 more than the total number of files since it includes the 'total' line at the top in the count.
|
That's why you should just use ls | wc -l
(In Aix at least. Guess it's the same with Linux. Writing this in Windows, and I don't want to boot my Sarge up to test it )
|
|
|
03-01-2005, 12:54 PM
|
#6
|
Member
Registered: Aug 2004
Location: Davis, California
Distribution: Gentoo, always Gentoo.
Posts: 159
Rep:
|
I'm a purist. 'ls' alone works, but it doesn't look like it should.
I suppose 'ls -1' (that's a one, not an ell)would both work properly and meet my condition of "looking" right as well.
|
|
|
03-01-2005, 12:58 PM
|
#7
|
LQ Newbie
Registered: Feb 2005
Location: Denmark
Distribution: Debian Lenny
Posts: 7
Rep:
|
Quote:
Originally posted by dsegel
I'm a purist. 'ls' alone works, but it doesn't look like it should.
|
You pipe ls to wc, so you won't see the output of ls at all
|
|
|
03-01-2005, 01:00 PM
|
#8
|
Member
Registered: Aug 2004
Location: Davis, California
Distribution: Gentoo, always Gentoo.
Posts: 159
Rep:
|
Quote:
Originally posted by GoodVibrations
You pipe ls to wc, so you won't see the output of ls at all
|
I know it's there.
|
|
|
03-01-2005, 01:16 PM
|
#9
|
LQ Newbie
Registered: Feb 2005
Location: Denmark
Distribution: Debian Lenny
Posts: 7
Rep:
|
Quote:
Originally posted by dsegel
I know it's there.
|
You are a purist!
|
|
|
All times are GMT -5. The time now is 12:21 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|