Removing 'bad'chrs from a file

Sandy Harris sandyinchina at
Fri Oct 8 07:26:28 UTC 2010

On Fri, Oct 8, 2010 at 3:13 PM, rikona <rikona at> wrote:

> Or, is there a way to just fix/remove the 'bad chrs' from a file? All
> [reasonable] {gotta watch out on this list :-) } ideas welcome.

You can do that with tr(1). You'd have to know what the
app means by "bad chrs", though.

tr -d '\0' < infile > outfile

should delate (-d) all null characters. To replace them with

tr '\0'  '\012' < infile > outfile

That's off the top of my head, quite likely has syntax
errors, but it should give you the idea. Check the man
page and it should be easy from there.

More information about the ubuntu-users mailing list