HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Count total files and Subdir with find & ll –lR is...
Operating System - HP-UX
1832532
Members
8002
Online
110043
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
05-18-2006 05:04 AM
05-18-2006 05:04 AM
When I tried to count total number of files and subdirectories (recursive), I got different results? Which on is correct?
/log_output#find . | wc -l
49541
/log_output#ll -lR|wc -l
83216
Thanks,
Gulam.
/log_output#find . | wc -l
49541
/log_output#ll -lR|wc -l
83216
Thanks,
Gulam.
Everyday Learning.
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2006 05:11 AM
05-18-2006 05:11 AM
Solution
Hi Gulam:
An quick examination of the output will show you the difference --- the 'find' is accurate; the 'll' is *not*.
# cd /tmp; ll -lR | more
.
.
.
./sp6287:
total 4
-rw-r----- 1 root sys 44 Mar 23 09:45 SOURCE_ME
-rw-r----- 1 root sys 86 Mar 23 09:45 gentmp
NOTE the total block count for the subdirectory. There are blank lines, too to separate subdirectories from one another, inflating the lines counted.
Regards!
...JRF...
An quick examination of the output will show you the difference --- the 'find' is accurate; the 'll' is *not*.
# cd /tmp; ll -lR | more
.
.
.
./sp6287:
total 4
-rw-r----- 1 root sys 44 Mar 23 09:45 SOURCE_ME
-rw-r----- 1 root sys 86 Mar 23 09:45 gentmp
NOTE the total block count for the subdirectory. There are blank lines, too to separate subdirectories from one another, inflating the lines counted.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2006 06:26 AM
05-18-2006 06:26 AM
Re: Count total files and Subdir with find & ll –lR is different?
For an accurate count with ll you need to exclude some lines i.e.
# ll -lR . | egrep -v '^$|^total|^\.' | wc -l
The above should give you the same count as the find below:
# find . | wc -l
cheers!
# ll -lR . | egrep -v '^$|^total|^\.' | wc -l
The above should give you the same count as the find below:
# find . | wc -l
cheers!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2006 08:38 AM
05-18-2006 08:38 AM
Re: Count total files and Subdir with find & ll –lR is different?
The ll command is producing several extra lines per directory. One is a blank line separating each new directory, the name of the directory which was already listed previously, then a total line. So for every directory, you'll have 4 extra lines using ll.
It's better to count directories and files separately:
echo "Directories:"
find /someplace -type d | wc -l
echo "Files:
find /someplace -type f | wc -l
Bill Hassell, sysadmin
It's better to count directories and files separately:
echo "Directories:"
find /someplace -type d | wc -l
echo "Files:
find /someplace -type f | wc -l
Bill Hassell, sysadmin
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP