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.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
03-17-2004, 10:29 PM
|
#1
|
|
LQ Newbie
Registered: Mar 2004
Posts: 13
Rep:
|
counting number of files
Is there a command in Linux counting the number of files in a directory and all its subdirectories?
|
|
|
|
03-17-2004, 10:46 PM
|
#2
|
|
Member
Registered: Jul 2003
Distribution: FreeBSD 8.2 RELEASE
Posts: 607
Rep:
|
ls -R | wc -l
|
|
|
|
03-18-2004, 01:25 AM
|
#3
|
|
LQ Newbie
Registered: Mar 2004
Posts: 13
Original Poster
Rep:
|
Quote:
Originally posted by Kovacs
ls -R | wc -l
|
is there a better solution in stead of counting number of lines?
|
|
|
|
03-18-2004, 01:49 AM
|
#4
|
|
Guru
Registered: Aug 2003
Location: Sydney, Australia
Distribution: Gentoo
Posts: 1,796
Rep:
|
maybe
Code:
find . -type f | wc -l
?
that doesnt count symbolic links though
|
|
|
|
03-18-2004, 01:56 AM
|
#5
|
|
Moderator
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,916
|
None I know of in standard installations ... but you
can probaly write something in C.
Cheers,
Tink
|
|
|
|
03-25-2004, 01:48 PM
|
#6
|
|
LQ Newbie
Registered: Mar 2004
Posts: 1
Rep:
|
Counting number of files
Here is a small script to count the number of files directories and sym links in a directory.
----------------
let COUNT=0
for i in $1/*
do
let COUNT+=1
done
echo $COUNT
----------------
example command:
count ./
with a few more modifications to the script it could count all files in sub directories also.
Enjoy!
|
|
|
|
03-25-2004, 01:53 PM
|
#7
|
|
Moderator
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,916
|
Re: Counting number of files
Quote:
Originally posted by jkunkel
----------------
let COUNT=0
for i in $1/*
do
let COUNT+=1
done
echo $COUNT
----------------
|
You sure that's more efficient than
? :)
Cheers,
Tink
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 11:00 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
|
|