![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Auto copy for files from folder to folder upon instant writing | Bashar | UNIX for Advanced & Expert Users | 2 | 08-21-2008 02:44 PM |
| foreach loop | ROOZ | Shell Programming and Scripting | 3 | 06-05-2008 03:20 PM |
| foreach loop | abch624 | Shell Programming and Scripting | 1 | 03-19-2008 09:34 PM |
| Parse the .txt file for folder name and FTP to the corrsponding folder. | MeganP | Shell Programming and Scripting | 3 | 07-03-2007 01:54 PM |
| foreach command ?! | geoquest | UNIX for Dummies Questions & Answers | 5 | 05-20-2002 05:11 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
foreach folder
Hi,
I'm having a small issue here and I can't get it to work. I'm programming a script for bash and I need to do something to all the folder in a directory. So I'm in the directory and I want to use the foreach statement but I dont know how to reference all the folders of that directory. To make things simplistic here's my code: Code:
foreach instance (.) cd instance mkdir test end |
|
||||
|
A small correction blowtorch.
Code:
for file in *; do
if [ -d $file ]; then
mkdir $file/test;
fi
done
Last edited by lorcan; 08-11-2007 at 07:51 AM.. |
|
||||
|
Quote:
current directory: a b c Inside of each directory there is a file here (using a as an example): a/test/folder/script.sh Sorry for the generic names. Now what I want my script to do is access that script.sh in each folder and run it. I was gonna do the for statement and then cd into that path and then do an execute command but I guess it's not that simple. Any ideas? thanks! |
| Sponsored Links | ||
|
|