Re: dir/list of files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Alexander Dalloz schrieb:

Laurence Orchard schrieb:

On Tue, 2006-08-01 at 14:55 -0700, bruce wrote:

simple question.. can't find the answer.. how do i do a list of files/dir,
and get the number of files in the dir ....

ls | wc -l

Not really, as that mixes dirs and files. So for a directory with files and subdirs the result of

ls | wc -l    !=   find . -type f | wc -l

Have to correct myself: what I meant was:

find . -type f -maxdepth 1 | wc -l


And hidden files and dirs are not counted as well.


for dir in $(find /home/image/ -type d)
   do echo ">> current dir: ${dir}"
       find ${dir} -type f
       echo -n "<< number of files: "
       find ${dir} -type f | wc -l
       echo
   done

Corrected here too:

for dir in $(find /home/image/ -type d)
  do echo ">> current dir: ${dir}"
      find ${dir} -type f - maxdepth 1
      echo -n "<< number of files: "
      find ${dir} -type f -maxdepth 1 | wc -l
      echo
  done


Alexander

Alexander



[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux