Home Man
Search
Today's Posts
Register

This forum is closed for new posts. Please post beginner questions to learn unix and learn linux in the UNIX for Beginners Questions & Answers forum.

ls command for listing the number of files

Tags
beginners

 

 
Thread Tools Search this Thread
# 1  
Old 03-23-2007
ls command for listing the number of files

I've searched the man page for an option for the ls command to print the number of files in a directory. I'm moving files and folders around and thought a count of files would be a quick way to determine if I was missed one somewhere. Some "unix's" shells do this I think... maybe linux...

Anybody know how to do this real quick

System is: SunOS 5.10 Generic sun4u sparc SUNW,Ultra-5_10 KSH

I did this but is comes back with byte count rather than a file count.
ls -l |wc


Thanks All )
# 2  
Old 03-23-2007
ls -l | wc -l
# 3  
Old 03-23-2007
Dang.... I knew I was close...

Thx Jim
# 4  
Old 03-23-2007
one little minor problem, at least what i have encountered, is that ls -l list out the files, including the "total" line on the very first line. wc -l will count that line too. So its just sufficient to exclude the switch , or use ls -1 instead.
# 5  
Old 03-24-2007
Quote:
Originally Posted by jimmyc
I've searched the man page for an option for the ls command to print the number of files in a directory. I'm moving files and folders around and thought a count of files would be a quick way to determine if I was missed one somewhere. Some "unix's" shells do this I think... maybe linux...

Anybody know how to do this real quick

System is: SunOS 5.10 Generic sun4u sparc SUNW,Ultra-5_10 KSH

I did this but is comes back with byte count rather than a file count.
ls -l |wc

You can add the -l option to wc, or you can do it in the shell itself, which will be much faster:
Code:
set -- *
echo $#

 

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Getting files through find command and listing file modification time upto seconds Nitesh sahu AIX 4 11-17-2015 08:51 AM
Listing only the files under a directory from the result of find command DJose UNIX for Dummies Questions & Answers 3 08-06-2015 11:15 AM
Unix Command for listing files containing one text but not other. gauravgautam135 UNIX for Dummies Questions & Answers 4 11-20-2013 09:36 AM
SFTP Command Help - listing files slufoot80 Solaris 1 01-09-2013 04:32 PM
command to verify number of files Mr.AIX AIX 3 02-15-2011 09:36 AM
Long listing of files using find command on remote server via SSH atukuri UNIX for Dummies Questions & Answers 2 04-20-2010 01:13 PM
Help with command to Move files by X number to seperate directories Geo_Bean Shell Programming and Scripting 8 03-26-2010 06:10 AM
find command -- listing files twice Straitsfan UNIX for Dummies Questions & Answers 2 01-11-2010 01:23 AM
TAR command , listing backed up files FredSmith Solaris 3 10-03-2005 10:08 AM
Recursive directory listing without listing files psingh UNIX for Dummies Questions & Answers 4 05-10-2002 10:52 AM


All times are GMT -4. The time now is 04:25 PM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password