timothy1
asked on
Unix Commands
What is the command if any, to retrieve the number of files in the current directory?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
oops, forgot to use -B option for all above ls commands (in case of people are using crazy filenames)
Oops, you're right about the -a.
Don't know if I'd consider that last one an improvement :-)
Don't know if I'd consider that last one an improvement :-)
> .. an improvement
probaly not if you pipe it to wc
but you'll be supprised (just viewing), sometimes ;-)
oops, and just found an example where all the ls|wc suggestions fail (including mine):
touch 'a\^Jb'; ls|wc
# where ^J is ctrl-V followed by return
I think a sulution for this is find, or ls -i|awk 'sophisticated prog here'
probaly not if you pipe it to wc
but you'll be supprised (just viewing), sometimes ;-)
oops, and just found an example where all the ls|wc suggestions fail (including mine):
touch 'a\^Jb'; ls|wc
# where ^J is ctrl-V followed by return
I think a sulution for this is find, or ls -i|awk 'sophisticated prog here'
ls -a|wc -l
> If you want only regular files in the current directory:
ls -Fa|egrep '[/|@%=]$'|wc -l
> If you want only regular files, but recursively:
ls -FaR|egrep '[/|@%=]$'|wc -l
;-)