UNIX Script to chmod other scripts?

techi3

In Runtime
Messages
119
Would it be possible to write a script to chmod all files ending in .sh to change permissions to say 777?

I'm practicing my UNIX Scripting and before I run the script from the command-line I have to change the execution bit or I get denied.

I would like to create all my scripts then run my, I'll call it "chmod.sh" which would "chmod 777 *.sh" all my .sh file. Is this possible, if so, how would I go about writing this script?

Thank You. :)
 
What would the actual script look like. Would it a for-in-do style?

for %%d in (/home/john) do chmod 777 *.sh

I'm not sure where the second part of the variable would go or if I would need it.
 
You don't *need* the loop at all - that's what the wildcard does (applies the chmod operation to each shell script in the current folder.) It's literally just:

chmod 777 *.sh
 
Back
Top Bottom