fizwit / filesystem-reporting-tools

Tools to help system administors manage very large file systems. pwalk
GNU General Public License v2.0
22 stars 12 forks source link

feature request add --depth to limit directory depth #12

Closed fizwit closed 5 years ago

malcook commented 6 years ago

nice - actually it would be GRAND to integrate the other filters available in 'find', expecially:

-d -depth -maxdepth -mindepth -amin -anewer -atime -cmin -cnewer -ctime -mmin -mnewer -mtime -iname -name -ipath -path -regex -uid -user

just sayin'

fizwit commented 6 years ago

The next feature will be the -x flag from du. -x "Skip directories that are on different filesystems from the one that the argument being processed is on." Crossing file systems and or mount points can give very inaccurate information if you are monitoring volume growth. I will use the st_dev flag from stat to detect this. The other flags from find are easy to implement as filters with Perl/Python. (but I guess depth would be easy also to implement as a filter also).

fizwit commented 6 years ago

depth flag is done, Below is a demo of how it works. Similar to --maxdepth of find

mkdir -p zero/one/two/three/four touch zero/one/two/fileAt2 touch zero/one/two/three/fileAt3

./pwalk --depth 2 ~/zero 2>/dev/null | awk 'BEGIN{FS=","}{print $4}' "/Users/john/zero" "/Users/john/zero/one" "/Users/john/zero/one/two/fileAt2" "/Users/john/zero/one/two"