LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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

Reply
 
Search this Thread
Old 03-01-2005, 11:44 AM   #1
canuck_barlow
Member
 
Registered: Dec 2004
Distribution: Fedora Core 5
Posts: 64

Rep: Reputation: 15
Directory Summary Command


Is there a command that will provide the number of files in a given directory?
 
Old 03-01-2005, 11:49 AM   #2
pharmd
Member
 
Registered: Feb 2005
Location: South Carolina
Distribution: Ubuntu 6.06 LTS
Posts: 83

Rep: Reputation: 15
"ls" maybe?..i dont think that gives number of files just lists all the files
 
Old 03-01-2005, 11:50 AM   #3
canuck_barlow
Member
 
Registered: Dec 2004
Distribution: Fedora Core 5
Posts: 64

Original Poster
Rep: Reputation: 15
I don't I can use ls for this. I've tried the different types ls but they don't work.
 
Old 03-01-2005, 12:04 PM   #4
dsegel
Member
 
Registered: Aug 2004
Location: Davis, California
Distribution: Gentoo, always Gentoo.
Posts: 159

Rep: Reputation: 30
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.
 
Old 03-01-2005, 12:13 PM   #5
GoodVibrations
LQ Newbie
 
Registered: Feb 2005
Location: Denmark
Distribution: Debian Lenny
Posts: 7

Rep: Reputation: 0
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 )
 
Old 03-01-2005, 12:54 PM   #6
dsegel
Member
 
Registered: Aug 2004
Location: Davis, California
Distribution: Gentoo, always Gentoo.
Posts: 159

Rep: Reputation: 30
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.
 
Old 03-01-2005, 12:58 PM   #7
GoodVibrations
LQ Newbie
 
Registered: Feb 2005
Location: Denmark
Distribution: Debian Lenny
Posts: 7

Rep: Reputation: 0
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
 
Old 03-01-2005, 01:00 PM   #8
dsegel
Member
 
Registered: Aug 2004
Location: Davis, California
Distribution: Gentoo, always Gentoo.
Posts: 159

Rep: Reputation: 30
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.
 
Old 03-01-2005, 01:16 PM   #9
GoodVibrations
LQ Newbie
 
Registered: Feb 2005
Location: Denmark
Distribution: Debian Lenny
Posts: 7

Rep: Reputation: 0
Quote:
Originally posted by dsegel
I know it's there.
You are a purist!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
My short summary - what do you think Artik Debian 3 05-23-2005 06:53 AM
CORE Linux command summary? crewmagnum Linux - Distributions 3 01-28-2005 10:48 AM
log summary? ryedunn Linux - Security 1 12-31-2004 09:48 AM
cp directory command mark001 Linux - Newbie 5 09-19-2004 01:00 AM
Traffic summary mikeshn Linux - Software 3 03-01-2004 10:48 AM


All times are GMT -5. The time now is 05:45 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration