[NTLUG:Discuss] What scripting change do I need to make?

Leroy Tennison leroy.tennison at verizon.net
Mon Oct 5 21:46:08 CDT 2015


Thanks for asking, the original thinking was concerning building a 
"calendar" tree.  There are (usually compliance-related) situations 
where documents as proof of activities are required daily. Something 
like 'mkdir -p 
2016/{Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec}/{`seq -s, 1 31`}' 
would produce a year's structure (and, of course, changing 2016 t0 
{2016,2017,2018} could produce multi-year - that's if `seq ...` would 
work).  Granted, you have to remove 31 for five months and 30 along with 
(usually) 29 for February but that's small "retrofit" for a calendar 
year's worth of structured directory creation.

What I've discovered about the problem is that I can get the undesired 
results with 'mkdir -p test/{'1,2,3'}' which leads me to believe that 
possibly the problem is that the `seq ...` substitution is causing mkdir 
to believe it's a string (even though the return of `seq ...` contains 
no quotes).  The same thing happens with $variable.

Yes, I could use progressive 'for ...' loops but I was hoping for 
something simple (it's known as being lazy...).  If only there was a way 
to tell mkdir "this isn't a string!".

On 10/05/2015 12:44 AM, Robert Citek wrote:
> I find your original version using braces more readable. What's your
> rationale for wanting to use seq?
>
> Regards,
> - Robert
>
> On Saturday, October 3, 2015, Leroy Tennison <leroy.tennison at verizon.net>
> wrote:
>
>> Thanks, that works (had to refresh my printf understanding).
>>
>> On 10/03/2015 04:31 AM, Patrick R. Michaud wrote:
>>
>>> How about...?
>>>
>>>       mkdir -p `seq -f "test/%g" 1 3`
>>>
>>> Pm
>>>
>>> On Sat, Oct 03, 2015 at 12:36:25AM -0500, Leroy Tennison wrote:
>>>
>>>> Using
>>>>
>>>>       mkdir -p test/{1,2,3}
>>>>
>>>> creates test/1, test/2 and test/3 as expected.  However
>>>>
>>>>       mkdir -p test/{`seq -s, 1 3`}
>>>>
>>>> creates test/{1,2,3}
>>>>
>>>> What do I need to do to get the "seq" variant to produce the same result
>>>> as
>>>> the first command?
>>>>
>>>>
>>>> _______________________________________________
>>>> http://www.ntlug.org/mailman/listinfo/discuss
>>>>
>>> _______________________________________________
>>> http://www.ntlug.org/mailman/listinfo/discuss
>>>
>>>
>> _______________________________________________
>> http://www.ntlug.org/mailman/listinfo/discuss
>>
> _______________________________________________
> http://www.ntlug.org/mailman/listinfo/discuss
>




More information about the Discuss mailing list