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.
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
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
2. UNIX for Dummies Questions & Answers
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
3. UNIX for Dummies Questions & Answers
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
4. Shell Programming and Scripting
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
5. UNIX for Dummies Questions & Answers
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
6. Shell Programming and Scripting
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
7. Shell Programming and Scripting
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
8. UNIX and Linux Applications
i think it is the same in both... Iam i right? (1 Reply)
Discussion started by: sumaiya
1 Replies
9. UNIX for Dummies Questions & Answers
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
10. Shell Programming and Scripting
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
CHMOD(3) 1 CHMOD(3)
chmod - Changes file mode
SYNOPSIS
bool chmod (string $filename, int $mode)
DESCRIPTION
Attempts to change the mode of the specified file to that given in $mode.
PARAMETERS
o $filename
- Path to the file.
o $mode
- Note that $mode is not automatically assumed to be an octal value, so to ensure the expected operation, you need to prefix $mode
with a zero (0). Strings such as "g+w" will not work properly.
<?php
chmod("/somedir/somefile", 755); // decimal; probably incorrect
chmod("/somedir/somefile", "u+rwx,go+rx"); // string; incorrect
chmod("/somedir/somefile", 0755); // octal; correct value of mode
?>
man 1 chmod' and ' man 2 chmod'.
<?php
// Read and write for owner, nothing for everybody else
chmod("/somedir/somefile", 0600);
// Read and write for owner, read for everybody else
chmod("/somedir/somefile", 0644);
// Everything for owner, read and execute for others
chmod("/somedir/somefile", 0755);
// Everything for owner, read and execute for owner's group
chmod("/somedir/somefile", 0750);
?>
RETURN VALUES
Returns TRUE on success or FALSE on failure.
NOTES
Note
The current user is the user under which PHP runs. It is probably not the same user you use for normal shell or FTP access. The
mode can be changed only by user who owns the file on most systems.
Note
This function will not work on remote files as the file to be examined must be accessible via the server's filesystem.
Note
When safe mode is enabled, PHP checks whether the files or directories you are about to operate on have the same UID (owner) as the
script that is being executed. In addition, you cannot set the SUID, SGID and sticky bits.
SEE ALSO
chown(3), chgrp(3), fileperms(3), stat(3).
PHP Documentation Group CHMOD(3)