[clug] Thursday afternoon Perl/bash golf time

Hal Ashburner hal at ashburner.info
Thu Jun 11 00:36:37 MDT 2015


cat failed? shell didn't pass the large number of args? Perl failed?
What values of "a large number" ?

2) looks good enough on prejudice fwiw.

On 11 June 2015 at 16:26, Andrew Janke <a.janke at gmail.com> wrote:
> I have a perl script, one of its jobs is to concatenate a large number
> of (binary) files together.
>
> I cheat and use the shell
>
> # create rawfile
> @args = ('cat', @catfiles, '>', "$opt{'tmpdir'}/all.raw");
> &do_cmd(join(' ', @args));
>
> (from: http://git.io/vIM2p)
>
> Of course now someone tried to use it with a large number of input
> files and it failed. So what to do?
>
> 1) for($i=0; $i<$#catfiles; $i+=100){
>          system("cat @catfiles[$i..$i+99] /tmp/cat-$i");
>          }
>
>      # cat the bits.
>
>
> 2) Do it in bash
>
>      for i in infiles.txt; do cat $i >> result; done
>
>
> 3) Do it in perl
>
>
> 4) Something far more clever.
>
> Suggestions welcome, my brain is slowing.
>
> ta
>
>
>
> a
> --
> linux mailing list
> linux at lists.samba.org
> https://lists.samba.org/mailman/listinfo/linux


More information about the linux mailing list