Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

The command has to be

ls -ld

Just from viewing the output of this, how can I determine how many files are in this directory?

share|improve this question

marked as duplicate by jasonwryan, Anthon, goldilocks, Renan, slm Nov 18 '13 at 1:34

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1  
Please don't do this: you have already asked this question: reposting it is a waste of everyone's time. –  jasonwryan Nov 17 '13 at 20:14

2 Answers 2

Easily achieve with the power of grep and word count :) Although are you sure you want the d in there?

ls -ld | grep ^- | wc -l

share|improve this answer
    
I have stated that the command has to be ls -ld Can it be determined just from looking at the output? –  John Nov 17 '13 at 20:49

Without additional arguments, ls -ld will only tell you the permissions of the current directory

cd /
ls -ld
drwxr-xr-x 23 root root 4096 Oct  7 15:57 .

If you want to find the number of entries (files, directories, links) in the current directotry, you can use

ls | wc -l

or if you just want the number of regular files

find . -maxdepth 1 -type f | wc -l
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.