ls command for listing the number of files


 
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 Smilie)
# 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 $#

 

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Getting files through find command and listing file modification time upto seconds Nitesh sahu AIX 4 11-17-2015 08:51 AM
Challenge in finding listing class method and its number of code lines steve32001 Shell Programming and Scripting 0 08-22-2015 05:04 PM
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 to count number of files in subdirectories ravikirankethe UNIX for Dummies Questions & Answers 4 03-17-2014 04:50 PM
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 split the files based on the number of lines in it malaya kumar UNIX for Dummies Questions & Answers 12 03-29-2012 06:00 AM
Command for total number of files (and size) across subdirectories? Beun UNIX for Dummies Questions & Answers 9 09-01-2011 11:17 AM
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
unix command to cound the number of files in a folder manas6 UNIX for Dummies Questions & Answers 6 04-21-2008 08:03 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