chmod on 690k files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting chmod on 690k files
# 8  
Old 01-04-2010
One could write a script that fetches the file list via FTP, generates an FTP script to run a 'site chmod' on each one, and the execute said FTP script. But for a one-shot thing that's probably overkill.

One question that I have to ask: why do you want to change the permissions to 755, making them executable? Isn't 644 (-rw-r--r--) enough?

As for your required script:
Code:
#!/bin/sh

echo "Content-Type: text/plain"
echo

find /home/username/path/to/photos/ -type f -iname '*.jpg' -exec chmod -v 0644 {} \;

If anyone wants to expand this code with error checking and whatsnot, feel free to do so.
# 9  
Old 01-04-2010
Hello everyone. I was able to schedule a cronjob that did the work. Thanks to all three of you for coming up with the command. It took about 20 minutes to get the 640k files.

@pludi, you are right, 644 would be plenty. I will make it them 644 now. Thanks again.
# 10  
Old 01-04-2010
Quote:
Originally Posted by pludi
One could write a script that fetches the file list via FTP, generates an FTP script to run a 'site chmod' on each one, and the execute said FTP script. But for a one-shot thing that's probably overkill.

One question that I have to ask: why do you want to change the permissions to 755, making them executable? Isn't 644 (-rw-r--r--) enough?

As for your required script:
Code:
#!/bin/sh

echo "Content-Type: text/plain"
echo

find /home/username/path/to/photos/ -type f -iname '*.jpg' -exec chmod -v 0644 {} \;

If anyone wants to expand this code with error checking and whatsnot, feel free to do so.
Just one doubt, correct me if am wrong,
shouldn't find be used with xargs instead of exec as there are more number of arguments churned out by find.
# 11  
Old 01-11-2010
Quote:
Originally Posted by matrixmadhan
Just one doubt, correct me if am wrong,
shouldn't find be used with xargs instead of exec as there are more number of arguments churned out by find.
Not sure, but I just used the commands what the gurus had posted.
# 12  
Old 01-11-2010
From the man page of (in this case GNU) find (emphasis added):
Quote:
The string `{}' is replaced by the current file name being processed everywhere it occurs in the arguments to the command, not just in arguments where it is alone, as in some versions of find.
So, for every file that matches against the filters chmod is called once, and only for that file. You'll need xargs if you want to run the command on more than one file at the same time. GNU find even improves this an adds a variant of -exec that can run the command on multiple files at once, when usually you'd need xargs for that.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Chmod list of files

Hi, I have a list of files in a text file. I want to change the mode of every one of those files, but am having difficulty in doing so. #!/bin/bash files=/home/david/files.txt for $item in $files { chmod 640 $item } .. doesn't cut it. Can anyone help? Thanks. (7 Replies)
Discussion started by: davidm123SED
7 Replies

2. UNIX for Dummies Questions & Answers

Change chmod on files in diff directories

I am looking for a small script to crawl through several directories and change a couple of files in each directory to read write status. Anyone have any ideas ? (5 Replies)
Discussion started by: zapper222
5 Replies

3. UNIX and Linux Applications

What is the difference between chmod in solaris and chmod in Linux?

i think it is the same in both... Iam i right? (1 Reply)
Discussion started by: sumaiya
1 Replies

4. Shell Programming and Scripting

chmod for great number of files

Hi all, I have a script who generate as an output a lot of files (the number is highly variable : 500 to more than 10000). At the end of this script I need to do a "chmod" on all those files. I tried but it says -bash: /bin/chmod: Argument list too long So it seems that chmod can't... (9 Replies)
Discussion started by: Moumou
9 Replies

5. Shell Programming and Scripting

chmod a lot of files

So i have about 600gb of data.. in which there are alot of directories and alot of files.. Im trying to put this on a ftp server.. So i want to set the permissions on the directories to be 755 and the permission on the files to be 644. So i used: find . -type d -exec chmod 755 {}\; and find .... (6 Replies)
Discussion started by: supermiguel
6 Replies

6. UNIX for Dummies Questions & Answers

chmod for files and directories

Hi, OS - Unix, linux (all unix flavors) My requirement. To check directory/file exists and then change the permission of the directories/files. Iam trying to start with directory and here is my code in the file totalchange.sh (insideragain - is a directory, test1.txt - is a file under the... (2 Replies)
Discussion started by: kenkanya
2 Replies

7. Shell Programming and Scripting

help with chmod (files only)

hello, i want to chmod 444 all files in a directory, files in subdirs cannot be chmoded same goes for the subdirs themself. So using: chmod -R 444 /dir/ won't work because it will chmod the directorys and files (together with files in subdirectorys) I figured out how to chmod files... (1 Reply)
Discussion started by: TehOne
1 Replies

8. UNIX for Dummies Questions & Answers

users need to chmod on newly ftp'd files

Is there a way to specify 774 permissions for a file uploaded to an app server via ftp without the users logging in and doing a chmod on the file they just put? I understand they were doing this with an old shared account, and it was working. When they started using their own accounts it stopped... (1 Reply)
Discussion started by: jgentile
1 Replies

9. UNIX for Dummies Questions & Answers

chmod command for recently modified files

hello! is there a way for me to use the chmod command to change permissions for several files all at once -based on the fact that these files were all most recently modified TODAY ? I can't use a wildcard on their filenames because the filenames are varied. But I was hoping I could somehow do... (2 Replies)
Discussion started by: polka_friend
2 Replies

10. UNIX for Advanced & Expert Users

Numeric CHMOD for .js files

Hello! At present, my .js files are also within the public_html directory. Anyone is able to type the name of these files in their browser address bar and then be presented the javascript (or text) code. What numeric CHMOD should be applied to these, which: Permit the world and group to... (3 Replies)
Discussion started by: Texan
3 Replies
Login or Register to Ask a Question