Home > Bookmarks, Linux, Tech > List number of files in a particular folder – Linux Command

List number of files in a particular folder – Linux Command

September 9th, 2009 Leave a comment Go to comments

Linux
Determine how many files there are in the current folder/directory:

many ways ;)

1.  list files and folders:

[root@server1]# du -a /folders/test | cut -d/ -f2 | sort | uniq -c | sort -nr
17616 data

2. list files and folders

[root@server1]# ls -Ra1 /folders/test|grep -v /|grep -vx ""|grep -vx "\.*"|wc -l
17731

3. list files:

[root@server1]# find /folders/test/ -name "*.*" -print | wc -l
17681

4. list files , links and folders:

[root@server1]# for t in files links directories; do echo `find /folders/test/ -type ${t:0:1} | wc -l` $t; done 2> /dev/null
17570 files
0 links
24 directories

5. list only files:

[root@server1]# for t in files; do echo `find /folders/test/ -type ${t:0:1} | wc -l` $t; done 2> /dev/null
17556 files

  1. No comments yet.
  1. No trackbacks yet.
GoCache - ByREV-Cache v1.0 - live served in : 0.145876 sec (gzip)