LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-10-2003, 11:42 PM   #1
ALF
Member
 
Registered: Oct 2002
Posts: 32

Rep: Reputation: 15
Number of files and directories


Hi,

I want to write a command to display number of files and folders inside a specific folder.

I tried ls with grep, but it didn't work perfect.

Thanks

ALF
 
Old 06-11-2003, 12:12 AM   #2
fancypiper
LQ Guru
 
Registered: Feb 2003
Location: Sparta, NC USA
Distribution: Ubuntu 10.04
Posts: 5,141

Rep: Reputation: 58
Try

ls -alc

Try out the different flags and combos of flags you see in:

man ls
info ls

You are bound to find something that fits like a glove in that drawer.
 
Old 06-11-2003, 12:34 AM   #3
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
If you just want bare numbers, how about 'ls -a | wc -w'? Or 'ls -a dirfoo | wc -w'?
 
Old 06-11-2003, 11:23 AM   #4
ALF
Member
 
Registered: Oct 2002
Posts: 32

Original Poster
Rep: Reputation: 15
I tried this, but you don't know how many files and how many folders. Also, some files have spaces in the file name, that is causing a problem too.

I'm trying now to ls -alF | Grep -e [^d]

to grep any line that starts with d (for directory) but it is not working. Any ideas?

ALF
 
Old 06-11-2003, 11:34 AM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
ls isn't a great tool for this. best to use a "find" instead
 
  


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
Number of files in directory bullium Linux - General 13 08-31-2011 09:50 AM
CHMOD directories.sub-directories.files zerojosh Linux - Software 2 11-19-2005 04:22 PM
List total number of directories paraiso Linux - Newbie 5 04-18-2005 05:04 AM
ProFTPd gives 'number files' Worstje Linux - Newbie 1 05-05-2004 10:19 AM
counting number of files akin81 Linux - Newbie 6 03-25-2004 02:53 PM


All times are GMT -5. The time now is 10:36 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration