- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Count total file command
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2001 09:37 PM
12-26-2001 09:37 PM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2001 09:46 PM
12-26-2001 09:46 PM
SolutionTo find the total number of files in your current directory and subdirectories, execute:
# find . -type f -print | wc -l
Hope this helps. Regards.
Steven Sim Kok Leong
Brainbench MVP for Unix Admin
http://www.brainbench.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2001 09:56 PM
12-26-2001 09:56 PM
Re: Count total file command
Try this:
# find dir_path -depth -type f -print | wc -l
HTH,
Shiju
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2001 05:33 AM
12-27-2001 05:33 AM
Re: Count total file command
To count files in your current directory only:
ll -a | grep ^- | wc -l
The ^ says to match lines beginning with the next character. You can change ^-
using the character from "man ls" shown below to count specific types of directory entries:
The first character indicates the entry type:
b Block special file
c Character special file
d Directory
l Symbolic link
n Network special file
p Fifo (also called a "named pipe") special file
s Socket
- Ordinary file
You can count multiple types using the format:
ll -a | egrep '^d|^-' | wc -l
To include sub-directories:
ll -aR | egrep '^-' | wc -l
Darrell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2001 04:54 AM
12-28-2001 04:54 AM
Re: Count total file command
$ ls -1 | wc -l
The -1 (thats the number one) causes ls to print one file name per line. Its a lot quicker than running ll because ls doesn't have to stat each file so its useful when you have a huge number of files in a directory.
Of course, if you want to include sub-directories as well the find command as already suggested is the way to go.
Regards,
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2001 05:24 AM
12-28-2001 05:24 AM
Re: Count total file command
Just a word of clarification - if you are piping the output of "ls", then you don't need to use the -1 switch. If the command is not outputting to a login device, e.g. a pipe, then it *defaults* to one entry per line.
Rgds, Robin.