# count file(s) under a specific directory

**URL:** <https://community.unix.com/t/count-file-s-under-a-specific-directory/152368>\
**Category:** Shell Programming and Scripting\
**Created:** [March 21, 2005, 2:04pm UTC](https://community.unix.com/t/count-file-s-under-a-specific-directory/152368 "2005-03-21T14:04:16Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![vgersh99](https://community.unix.com/user_avatar/community.unix.com/vgersh99/32/14851_2.png) [@vgersh99](https://community.unix.com/u/vgersh99)\
**Post date:** [March 21, 2005, 2:17pm UTC](https://community.unix.com/t/count-file-s-under-a-specific-directory/152368/2 "2005-03-21T14:17:39Z")

</div>

> [@leemjesse](#):
>
> How do I count number of file in a directory. Here is what I want to do.
> 
> 1. find total number of file in a directory in variable total

man find

> [@leemjesse](#):
>
> 1. ftp all the file

[FAQ](https://community.unix.com/t/automate-ftp-scripting-ftp-transfers/148989/1)

> [@leemjesse](#):
>
> 1. ftp\_return\_code=`grep -c "Transfer complete" $logfile`
> 
> if [$total == ftp\_return\_code]
> 
> then  
> exit 0
> 
> else
> 
> exit -1  
> fi

---

_[View the full topic](https://community.unix.com/t/count-file-s-under-a-specific-directory/152368)._
