[COFF] Shell script advice: using 'dd' to write multiple media
steve jenkin
sjenkin at canb.auug.org.au
Tue Jun 27 17:53:41 AEST 2023
Ralph,
Nice solution:
examine dd’s STDERR then ‘break’.
Thanks for the test script - I like your generation of characters using ‘dc’.
cheers!
steve
> On 27 Jun 2023, at 16:23, Ralph Corderoy <ralph at inputplus.co.uk> wrote:
>
> Hi Steve,
>
>> I’ve never figured out how to use ‘dd’ so it returns after a single
>> block is written doesn’t close the input, killing the pipeline, or
>> cause the rest of the data to be discarded.
>
> I think this meets your description and complies with POSIX's dd(1p)
> here.
>
> $ seq 33 126 | sed 's/$/P/' | dc |
>> while :; do
>> LC_ALL=C dd bs=10 count=1 2>dd.err | sed -n l
>> grep -q '^[^0].* records in$' dd.err || break
>> done
> !"#$%&'()*$
> +,-./01234$
> 56789:;<=>$
> ?@ABCDEFGH$
> IJKLMNOPQR$
> STUVWXYZ[\\$
> ]^_`abcdef$
> ghijklmnop$
> qrstuvwxyz$
> {|}~$
> $
> $ rm dd.err
>
> I set the locale so the format of dd's stderr report is known.
>
> --
> Cheers, Ralph.
--
Steve Jenkin, IT Systems and Design
0412 786 915 (+61 412 786 915)
PO Box 38, Kippax ACT 2615, AUSTRALIA
mailto:sjenkin at canb.auug.org.au http://members.tip.net.au/~sjenkin
More information about the COFF
mailing list