Mailinglist Archive: opensuse (1108 mails)

< Previous Next >
Re: [opensuse] How to remove binary garbage from the front of a binary file??
On 08/12/2018 01:00 PM, Bernhard Voelker wrote:
# Create a binary testfile file with a '!BDN' marker.
$ { cat /usr/bin/cat; printf '!BDN'; cat /usr/bin/cat; } > testfile

# Use awk(1) to print everything after and including the marker.
awk 'BEGIN{RS="!BDN";ORS=""} {if(n++)print}' < testfile > testfile2

Or use 'grep --byte-offset --binary-files=text --only-matching --fixed-strings'
to find
the marker (stripping off the matched pattern after and including the ':'):

$ n="$( grep -baoF '!BDN' testfile | cut -d: -f1 )"

and then let dd copy all from that position:

$ dd \
if=testfile \
of=testfile2-dd \
status=none \
bs=1 \
iflag=skip_bytes \

Have a nice day,

To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse+owner@xxxxxxxxxxxx

< Previous Next >