Linux: setup attributes based on type of entry(file or directory)
If you have to setup attributes on all directories from one tree, you can use 'find' and it's 'exec' argument or find and 'xargs'.
If you have a lot of directories, the preferred menthod is the second one, the ones that's using xargs:
If you have a lot of directories, the preferred menthod is the second one, the ones that's using xargs:
The same thing can be applied to files and, again, the preferred method is the second one:[root@centos6::/var/www/html]# find . -type d | wc -l
2589
[root@centos6:/var/www/html]# time find . -type d -exec chmod 2775 {} \;
real 0m2.168s
user 0m0.046s
sys 0m0.321s
[root@centos6:/var/www/html]# time find . -type d -print0 | xargs -0 chmod 2775
real 0m0.098s
user 0m0.021s
sys 0m0.078s
[root@centos6:/var/www/html]# find . -type f | wc -l
7403
[root@centos6:/var/www/html]# time find . -type f -exec chmod 664 {} \;
real 0m6.081s
user 0m0.070s
sys 0m0.819s
[root@centos6:/var/www/html]# time find . -type f -print0 | xargs -0 chmod 664
real 0m0.106s
user 0m0.024s
sys 0m0.137s
Comments
Post a Comment