BashScripts.org
http://bashscripts.org/forum/

display the total files
http://bashscripts.org/forum/viewtopic.php?f=8&t=1166
Page 1 of 1

Author:  svann [ Sun Aug 15, 2010 2:04 pm ]
Post subject:  display the total files

hello any ideea of a script which can display how many files are into a dir or how many dirs are in /

i whant to check some of my directories to see if the backup match with the current server files any ideea how it can be made? thanks

Author:  Patsie [ Mon Aug 16, 2010 2:43 pm ]
Post subject:  Re: display the total files

svann wrote:
hello any ideea of a script which can display how many files are into a dir or how many dirs are in /

i whant to check some of my directories to see if the backup match with the current server files any ideea how it can be made? thanks


To check the number of files in one directory you can just simple 'ls /path/to/directory | wc -l'
If you're talking recursively traversing all underlying subdirectories 'find /path/to/directory -type f | wc -l'
You can do the same with directories, just replace '-type f' with '-type d'
You're also talking about checking your backup. Just counting files or directories isn't a very robust way of doing that. Comparing md5 checksums would be a little better 'find /path/to/directory -type f -exec md5sum {} \;'

Page 1 of 1 All times are UTC - 6 hours
© 2000, 2002, 2005, 2007 phpBB Group • http://www.phpbb.com