[Ma-linux] How to get the number of files in a given directory

Janina Sajka janina at rednote.net
Thu Jan 10 20:49:34 EST 2008


Jay Hart writes:
> How can you get the number of files in a directory?
> 
> for example, say /usr/local/bin had ten files (not including . and ..)
> 
> What command(s) would I issue to get a return for the number of files, in this
> case 10, back at the command line?

ls -1p |grep -v '\''/'\'' |wc -l

It's simpler if you also want to count directories, of course:

ls -1 |wc -l

And, if you want only subdirectories:

ls -1p |grep '\''/'\'' |wc -l

hth

Janina

> 
> TIA,
> 
> Jay Hart
> 
> _______________________________________________
> Ma-linux mailing list
> Ma-linux at calypso.tux.org
> http://calypso.tux.org/cgi-bin/mailman/listinfo/ma-linux

-- 

Janina Sajka,	Phone:	+1.202.595.7777;	sip:janina at a11y.org
Partner, Capital Accessibility LLC	http://CapitalAccessibility.Com

Marketing the Owasys 22C talking screenless cell phone in the U.S. and Canada
Learn more at http://ScreenlessPhone.Com

Chair, Open Accessibility	janina at a11y.org	
Linux Foundation		http://a11y.org



More information about the Ma-linux mailing list