|
google site
|
|||||||
| Forums | Register | Blog | Man Pages | Forum Rules | Links | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
![]() |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Help with for loops
Hi, I am starting to enhance my scripting knowledge and need some assistance with simple 1 line for loops. This may help to do a mass permissions change on a big apache doc root while I have an insane customer on my phone.
What is the best resource to learn this skill and what are some that y'all have used in the past? Thanks for any assistance. |
| Sponsored Links | ||
|
|
|
#2
|
||||
|
||||
|
What shell are you using?
|
|
#3
|
|||
|
|||
|
I should have stated this...sorry
we use the bash shell mostly. |
|
#4
|
|||
|
|||
|
What exactly are you wanting the script to do? Think about:
o What are the specifications to the names of the files you wish to change? ie, every file in a directory or some specific set of file names? o All the files below that directory too? o Exclude any files or directories? o Script or a simple command? o Execute from any directory? o Check for errors or not? The biggest hint I have is think clearly about what you want before you script it. The shell will do exactly what it is TOLD, not what you WANT or EXPECT!!! |
|
#5
|
|||
|
|||
|
I'm not sure you need a loop because "chmod -R" might do what you want and if not then some "find" with "-exec" probably will.
However, if it's loops you want, this may get you started: 2005/06/02 Bash looping |
|
#6
|
|||
|
|||
|
Code:
for file in * ;do chmod +w $file(or whatever you want); done It is not necessary to do it this way, but this is a loop example for you. |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Loops | Shazin | Shell Programming and Scripting | 4 | 08-04-2009 09:09 AM |
| For Loops | msb65 | UNIX for Dummies Questions & Answers | 3 | 08-06-2008 05:00 PM |
| While Loops | vdc | UNIX for Dummies Questions & Answers | 4 | 05-10-2005 08:55 AM |
| Loops within loops | bthomas | Shell Programming and Scripting | 8 | 04-14-2005 01:09 PM |
| loops? | jonas27 | UNIX for Dummies Questions & Answers | 1 | 11-06-2001 02:28 AM |