LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-01-2010, 08:04 AM   #1
kez1985
LQ Newbie
 
Registered: Jan 2010
Posts: 1

Rep: Reputation: 0
for loop and nested find


Hi, I am trying to construct a script for migrating between 2 email servers which use maildir. One of which is using maildir under a chrooted jail for each domain and the other seperates out all email into a seperate folder(non-chroot).

My script thus far is below:

Code:
!/bin/bash
domains=(domain1.com domain2.com domain3.com domain4.com domain5.net)

for i in $domains; do
echo $i
find `find /home -maxdepth 3 -mindepth 3 -type d -name $i` -maxdepth 1 -mindepth 1 -type d
done
This script should look in /home/something/somethingelse for a directory with the same name as each domain in the array and then use the result of that search to see what directories are inside that parent directory. The find command works in the shell and provides the correct output, but when put into this for loop it seems to only provide the result for the first domain in the array, it does not print any further output for domain2.com etc... I'm a little stumped asto why the for loop is not continuing to step through the array.

Thanks, Kerry
 
Old 10-01-2010, 10:46 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Arch
Posts: 10,038

Rep: Reputation: 3203Reputation: 3203Reputation: 3203Reputation: 3203Reputation: 3203Reputation: 3203Reputation: 3203Reputation: 3203Reputation: 3203Reputation: 3203Reputation: 3203
Maybe if you used the array you created it might work a little better
Code:
for i in ${domains[*]}; do
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
nested loop-bash script- issue on logic yathin Linux - Newbie 6 05-31-2010 06:30 AM
Perl and nested loop substitution Evgeniy Arbatov Linux - General 2 04-28-2010 05:19 AM
Nested loop with 2 counters for 2 array variables briana.paige Linux - Newbie 2 06-19-2009 07:38 AM
nested loop in Perl help needed Grafbak Programming 9 12-19-2006 10:28 AM
Nested-double loop error Harry Seldon Programming 3 05-06-2006 05:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration