Re: How to remove nulls from a file

From: John DuBois (spcecdt_at_armory.com)
Date: 01/27/05


Date: 27 Jan 2005 22:43:34 GMT

In article <1106859286.522130.287300@c13g2000cwb.googlegroups.com>,
 <glenns@chartermi.net> wrote:
>Hello,
>Backgound - Unix Version - HPUX-11
>
>I receive product order files from a customer and noticed they seemed
>quite large in size.
>If I open them with "vi", I see the following at the bottom of the
>screen...
>
>"customer_data.inb " 860 lines, 22876 characters (65187 nulls)
>
>However, If I write the file back out to disk (w!) and re-open it, the
>(65187 nulls) message is gone !
>
>My question...
>Is there a Unix command I can run (tr, awk, etc.) to simulate what vi
>did when I wrote the file back out to disk?

tr -d '\0' < infile > outfile

(the original 'tr' does this w/o requiring the -d '\0', but this version will
work with both)

> What would I replace the
>'nulls' with ?

Nothing, if you want the same effect as open/writing with vi.
Presumably you have determined that the datafiles contain all the information
you need even after the nulls have been removed, though this seems a bit odd.

        John

-- 
John DuBois  spcecdt@armory.com  KC6QKZ/AE  http://www.armory.com/~spcecdt/


Relevant Pages

  • How to remove nulls from a file
    ... Backgound - Unix Version - HPUX-11 ... I receive product order files from a customer and noticed they seemed ... However, If I write the file back out to disk and re-open it, the ... (65187 nulls) ...
    (comp.unix.shell)
  • Re: XFS: how to NOT null files on fsck?
    ... Turns out my 1.2k fstab file is all "nulls". ... Now I know it takes a while before data may end up on disk and that it ... use larger file AU size (but I haven't seen to many of these IA64 machines ... Sad was the day that it was decided that the linux-kernel "corp" decided ...
    (Linux-Kernel)
  • Re: 3 value logic. Why is SQL so special?
    ... if I have a Customer table which has a lot of optional attributes (that ... CustomerBirthDate etc) to avoid NULLs? ... If *awful lot of overhead* is creating 3 extra tables to do it the ...
    (comp.databases.theory)
  • Re: Blank Date display problem
    ... using NULLs in date type of fields. ... 1900 instead of blank for the same records from the same database. ... Suppose you run a query with a left join, asking for each customer name from the ... and the date of their latest purchase from the related purchases ...
    (microsoft.public.vb.general.discussion)
  • Re: Create Big size dummy File..
    ... >> The stuff before is whatever garbage was on the disk. ... Why--what makes you think/say that? ... If it were to write all nulls (or ...
    (microsoft.public.vb.general.discussion)