Results 1 to 6 of 6
Can some one tell me how to change the file attribute of huge number of file. In my 4TB storage, I have to change the file (thousands of files) attribute ...
- 10-11-2007 #1Just Joined!
- Join Date
- Oct 2007
- Posts
- 1
Changing File attribute
Can some one tell me how to change the file attribute of huge number of file. In my 4TB storage, I have to change the file (thousands of files) attribute every now and then. At present I'm using chmod -R 775, but it takes hell lot of time to execute. If there any way to change the attribute of newly created/modified files only. Or can it be done through some script to make it faster?
Thanks in advance.
- Arun
- 10-11-2007 #2
Here is a Pseudo Script for you:
- Scan For all Files on System
- Write to file
- Chmod -R 775 (Maybe in threads)
That is the first and then the second is:
- Scan For all Files on System
- Write to Diffrent File.
- cmp files
- Flag the Diffrences
Well, I will write a better one later on.
But I dont feel like thinking now
I make a Bash Script or a Perl Script for you to do this.
But I will later on
Edit:
New idea:
MD5 -> Main Dirs
Check Old Hash
If Diffrent -> MD5 Dirs + chmod all in dir(In threads) else Do Nothing check next folder
- 10-11-2007 #3Linux Enthusiast
- Join Date
- Aug 2006
- Posts
- 631
With the find command you can search for files which don't have permision 775 and change the permission to 775 like this (replace "YourDir" with your directoryname):
Try to "ls -l" the files first to check if you get the correct files:Code:find YourDir -type f ! -perm 775 -exec chmod -R 775 {} \;
RegardsCode:find YourDir -type f ! -perm 775 -exec ls -l {} \;
- 10-11-2007 #4
- 10-14-2007 #5Just Joined!
- Join Date
- Oct 2007
- Location
- Barcelona
- Posts
- 1
Hi. Just two hints about this thread:
1.-For new files: set correctly the UMASK environment variable for all the users , processes & applications responsible for new files. "export UMASK=002" (binary complement of 755)
2.-For current files. Use a light variation to Frankiln52 approach, because with his command you finnish executing a lot of processes (forks), at least one for every affected file. This works faster, because chmod is called with a list of files as arguments:
find YourDir -type f ! -perm 775 | xargs chmod -R 775
cheers!
- 10-14-2007 #6Except, of course, you no longer need the -R.Code:
find YourDir -type f ! -perm 775 | xargs chmod -R 775


Reply With Quote