Remove non printing characters from file

How do I remove the printer escape sequence, the first 5 characters, that occurs on every 33rd line in a file, see hex dump of line 1.

0000    1e 00 00 00 00 0a 0a 0a  20 0a 20 20 20 20 20 20   ....
0010    20 20 20 20 20 20 20 20  20 20 0a 42 49 4c 4c 20       

Thanks,

Hello jgt,

I have a few to questions pose in response first:-

  • What have you tried so far?
  • What output/errors do you get?
  • What OS and version are you using?
  • What are your preferred tools? (C, shell, perl, awk, etc.)
  • What logical process have you considered? (to help steer us to follow what you are trying to achieve)

Most importantly, What have you tried so far?

You could have a sed, awk, shell script that reads trims and re-writes or even a tr might do the trick. A bit of context to where you are calling this would be good and I'm sure we can work it out.

We're all here to learn and getting the relevant information will help us all.

Kind regards,
Robin

The print file has a reset to 10 cpi at the beginning of every page.
Previously we were using smbclient with "translate -c" to convert the file from unix to dos, but when we changed to use netcat, it seems that the nulls are causing the record to be dropped.
I have tried variations of

s/\0031\0000//

with sed and vi to no avail.
What I would like is something like:

sed -f sed.inp <$file |netcat -h 192.168.1.1 -p 9100

---------- Post updated at 05:03 PM ---------- Previous update was at 04:49 PM ----------

figured it out.

tr -d "\036\000" <input >output