• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [OT] one more UNIX question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [OT] one more UNIX question


  • Subject: Re: [OT] one more UNIX question
  • From: "Mark J. Reed" <email@hidden>
  • Date: Wed, 13 Jun 2007 20:52:08 -0400

On 6/13/07, Bill Briggs <email@hidden> wrote:
the variable evaluates, but the shell fails to construct the tree using the list held in the variable.

Right, that's due to the order of evaluation. Brace expansion before variable expansion... which means this works:

mkdir {$a,$b,$c}/{$d,$e,$f}

no matter what $a, $b, $c, $d, $e, and $f contain, even if it's braces.

You have a couple options.  One is "eval" - the problem with eval is
that it re-evaluates everything, including some things you might not
want, and spaces, commas, quotation marks, etc will confuse the heck
out of it.

$ a="{a,b,c}"
$ eval "mkdir $a/$a"  # creates dirs a/a, a/b, ... c/b, c/c

Another option would be to use a loop.  Of course, the downside here
is that you wind up executing mkdir multiple times instead of just
once with a huge argument list.

tops=(list of sub folders)
subs=(sub sub folders)
for top in "${tops[@]}"; do
  for sub in "${subs[@]}"; do
   mkdir -pv "$top"/"$sub"
done
done







--
Mark J. Reed <email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
  • Follow-Ups:
    • Re: [OT] one more UNIX question
      • From: Bill Briggs <email@hidden>
    • Re: [OT] one more UNIX question
      • From: "Mark J. Reed" <email@hidden>
References: 
 >Email Change because of SPAM... (Sorry for the RESEND) (From: Don Wieland <email@hidden>)
 >Re: [OT] UNIX heads; can I do this? (From: "Mark J. Reed" <email@hidden>)

  • Prev by Date: Re: [OT] UNIX heads; can I do this?
  • Next by Date: Re: [OT] one more UNIX question
  • Previous by thread: Re: [OT] one more UNIX question
  • Next by thread: Re: [OT] one more UNIX question
  • Index(es):
    • Date
    • Thread