copying multiple files
David Henderson
dhenderson at digital-pipe.com
Tue Nov 22 13:50:15 UTC 2016
Good morning Jim, thanks for your help as well! After talking with
Grant yesterday it dawned on me that this must be a bash-ism. Your
suggestion is pretty good at cutting down on the amount of syntax to
deal with. It is certainly clearer than the hack I put together. :)
The reason that I want to make this the shortest command possible is
because I don't want to add 60 lines of code to a script just to copy
10 files (with error control and so forth).
Thanks,
Dave
On 11/21/16, Cathey, Jim <jcathey at ciena.com> wrote:
> So you've written a shell script that relies upon non-POSIX
> behavior, specifically GNU bash extensions, and it doesn't
> work in POSIX-ey ash. No big surprise. You will have to
> do it differently, or install bash on your target. Same
> dilemma everybody else faces when dealing with 'small' targets.
>
> What's _wrong_ with this kind of thing:
>
> P=/tmp/test cp -f $P/a $P/b $P/c ... dest/
>
> anyway? (I used $P to cut down the source line length, but
> it's totally unnecessary to the functionality.) It's not
> like you have to get everything done in one command, either.
> The cp command is not some kind of atomic operation. Are you
> after a fewest-line-count award?
>
> -- Jim
>
> -----Original Message-----
> From: busybox [mailto:busybox-bounces at busybox.net] On Behalf Of David
> Henderson
> Sent: Monday, November 21, 2016 2:07 PM
> To: Grant Edwards
> Cc: busybox at busybox.net
> Subject: Re: copying multiple files
>
> Thanks again for your continued help Grant. Unfortunately the file
> names are not actually similar as in the example (e.g. help.txt,
> world.png, ...) so using braces won't help either. Any other
> thoughts? Currently I'm forced to use a combination of find and cp -
> ugh - just to reduce the number of lines necessary for the
> operation...
>
> Thanks,
> Dave
>
>
> On 11/21/16, Grant Edwards <grant.b.edwards at gmail.com> wrote:
>> On 2016-11-21, David Henderson <dhenderson at digital-pipe.com> wrote:
>>> On 11/21/16, Grant Edwards <grant.b.edwards at gmail.com> wrote:
>>>> On 2016-11-21, David Henderson <dhenderson at digital-pipe.com> wrote:
>>>>
>>>>> cp -f /tmp/test/{a.txt,b.txt,c.txt} /tmp/test2/{1.txt,2.txt,3.txt}
>>>>> /tmp/dest
>>>>
>>>>> This keeps failing. Is this implemented in BB?
>>>>
>>>> Try this:
>>>>
>>>> $ busybox ash
>>>> ~ $ echo /tmp/test/{a.txt,b.txt,c.txt}
>>>> /tmp/test/{a.txt,b.txt,c.txt}
>>>>
>>>> It appears that the busybox shell does not implement bash/C shell
>>>> alternation (aka "brace expansion"). None of the busybox builds I
>>>> have on hand do anyway, and I don't see any options in the config file
>>>> to enable such a feature...
>>
>>> Hey Grant, thanks for the reply! Unfortunately that command will just
>>> echo what you type to the screen, not actually copy anything.
>>
>> I know. I was showing you how to determine if alternation (brace
>> expansion) wasn't happenning. It doesn't on any of my builds of
>> busybox.
>>
>>> Any other thoughts?
>>
>> Don't try to use alternation:
>>
>> cp -f /tmp/test/[abc].txt /tmp/test2/[123].txt /tmp/dest
>>
>> --
>> Grant Edwards grant.b.edwards Yow! ... I think I'd
>> at better go back to my
>> DESK
>> gmail.com and toy with a few
>> common
>> MISAPPREHENSIONS ...
>>
>> _______________________________________________
>> busybox mailing list
>> busybox at busybox.net
>> http://lists.busybox.net/mailman/listinfo/busybox
>>
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
>
More information about the busybox
mailing list