Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 26 Mar 2010 08:49:08 -0700
From:      Charlie Kester <corky1951@comcast.net>
To:        freebsd-questions@freebsd.org
Subject:   Re: Creating multiple directories simultaneously
Message-ID:  <20100326154907.GC84718@comcast.net>
In-Reply-To: <20100326074456.7139c3da@scorpio.seibercom.net>
References:  <20100326071248.4ec4ea5e@scorpio.seibercom.net> <20100326113258.GA9957@catflap.slightlystrange.org> <20100326074456.7139c3da@scorpio.seibercom.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri 26 Mar 2010 at 04:44:56 PDT Jerry wrote:
>On Fri, 26 Mar 2010 11:32:58 +0000, Daniel Bye
><freebsd-questions@slightlystrange.org> articulated:
>
>> On Fri, Mar 26, 2010 at 07:12:48AM -0400, Jerry wrote:
>> > I could have sworn that I saw a method of creating several
>> > directories, actually a parent direct and several sub-directories
>> > simultaneously; however, I cannot fine the documentation any longer.
>> >
>> > Assume I want to create a directory: FOO with three directories
>> > under it, foo-1, foo-2 and foo-3. I tried: mkdir -p foo {foo-1,
>> > foo-2, foo-3}
>>
>> Almost.
>>
>>  $ mkdir -p FOO/{foo-1,foo-2,foo-3}
>
>Thank you; that is exactly what I was looking for. I knew I had seen it
>somewhere before.

Or, for even less typing:

$ mkdir -p FOO/foo-{1,2,3}

Understand how this works, however, so you won't need to look it up
again, but can apply it yourself in whatever variation is needed. It's
called brace expansion.  Here's the first hit that comes up in Google,
which describes it fairly well:

http://snap.nlc.dcccd.edu/reference/bash1/features_11.html

This page is about the bash shell, but brace expansion works the same
way in tcsh.  It is NOT supported in tne Bourne shell.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100326154907.GC84718>