Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
4  
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
1  
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. –  Sukminder Mar 6 '13 at 19:42
add comment

1 Answer

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)
                if(c)
                        putchar(c);

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

Your Answer

 
discard

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.