On Fri, Dec 27, 2013 at 10:03:19AM -0800, Jim Meyering wrote:
> On Thu, Dec 26, 2013 at 7:47 PM, Ken Irving <[email protected]> wrote:
> >
> > ln -s $(printf '%0.sx' {1..256}) len256
> ...
>
> Just a note that your printf expression produces a result much longer
> than 256 bytes.
> You can use this to see the 255->256 transition:
>
> ...
> $ rm -f x; env ln -s $(printf '%0*d' 256 0) x; env ln -s a x
I think I'm seeing the expected number of bytes, having found the %0.s
format string via google. Could it be 'much longer' due to unicode or
other considerations? I'm having trouble breaking %0.s down, but I guess
it somehow specifies a max length of 0 bytes so only the x remains, with
the format string repeated 256 times.
$ printf '%0.sx' {1..256} | wc -c
256
Your version is better for the purpose, with the target length given
more explicitly.
$ printf '%0*d' 256 0 | wc -c
256
I thought there was a bash expansion to produce a run of bytes, but
couldn't find it.
Ken