Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am working with mainframe files and it seems that the low values (x'00') exists in the records in the file which throws off my import for fixed block.

Does anyone know how to eliminate those characters in Linux?

share|improve this question
Eliminate - you just want to delete them? or replace with sometihng? – gt6989b Mar 6 '13 at 18:02
What do you mean by "low values x'00'? The NUL character? What kind of files, any special format to them? What "mainframe" application did create them? – vonbrand Mar 6 '13 at 18:14
0x00 is used by various programs to delimiter values that can contain any character. E.g. a filename in Linux can have a newline character. To make a fool-proof list of filenames one would use 0x00 as separator and not \n. Thus a bit more context, as @vonbrand asks for could probably give a more usable answer. – Runium Mar 6 '13 at 19:42

If you just want to delete NUL characters, a proggie like this does the job:

#include <stdio.h>
#include <stdlib.h>

int main()
        int c;

        while((c = getchar()) != EOF)

share|improve this answer
There is already a program for stripping nul bytes: tr -d '\0' < infile > outfile – Lekensteyn Mar 6 '13 at 18:48
@Lekensteyn, not my day. Thanks! – vonbrand Mar 6 '13 at 19:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.