![]() |
chmod -R 755 *.cgi
Why does this command NOT work?
chmod -R 755 *.cgi chmod: getting attributes of `*.cgi': No such file or directory I want to recursively change every .cgi file to 755. Is there no way to do a wildcard and recurse at the same time with chmod? |
Looks like you need to recurse and wildcard before you chmod the .attribute.
If you chmod the 755 back to 745 it will also. |
You mean like this?
chmod -R *.cgi 755 chmod: invalid mode string: `*.cgi' |
Quote:
directories aren't *.cgi so the -R won't help, it won't get into the directories.... that's why it didn't work, but i don't know what should work, i almost have no clue about *nix .... so if you find the answer... please share it with us ;) |
I think you are right. How do I tell it to recurse a directory (the current directory) and apply the *.cgi wildcard at the same time?
|
.
|
Quote:
|
[edit]
I was wrong. This command does NOT work.: chmod -R 755 . *.cgi It changes ALL files. Same as running this command: chmod -R 755 . |
Told u
. :thumbsup |
Nope, I was wrong. That above command CHANGES ALL FILES just as running "chmod -R 755 ." would do.
FUCK! :feels-hot |
Anyone know how to do this? If it can not be done, I am going to have to code a script to do this because I have way too many files to manually change.
|
Hi,
cd to the directory and type: find -name '*.cgi' -exec chmod 755 {} \; Hope this helps. |
to summarize, keep this in mind.
your shell is what does the wildcard expansion. so when you type: chmod -R 755 *.cgi your shell expands *.cgi to a list of the files in the current directory that end with .cgi . this would also include directories (which are basically files) that happened to be named something.cgi . only after the expansion is done are the arguments actually sent to chmod. some shells will error out if there are no .cgi files. other shells (better shells) wil just pass '*.cgi' on to the chmod binary. chmod doesn't understand wildcards (most binaries don't, find is an exception) so it would try to change the permissions on a file called '*.cgi'. if that file was a directory it would change them recursively. fuqalot's post is correct. i'm just clarifying why this happens. |
Thanks for explaining how it works salsbury, that helps a lot. So wildcards and recursing are exclusive, which is what I thought, I just did not know exactly why.
|
Quote:
BTW, the "{}" is the list of files that find returns, right? What is the "\" for? |
Quote:
Quote:
|
Excellent. Thanks again.
|
All times are GMT -7. The time now is 10:27 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123