The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
cat /dev/null freakydancer UNIX for Dummies Questions & Answers 4 09-10-2008 12:34 PM
How to remove null characters from file? siegfried UNIX for Dummies Questions & Answers 1 04-01-2008 09:02 PM
compare null with non-null nitin Shell Programming and Scripting 8 11-04-2006 04:58 PM
> /dev/null rrs Shell Programming and Scripting 2 06-19-2006 01:29 AM
Null Value Khoomfire UNIX for Advanced & Expert Users 1 04-10-2006 06:55 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 08-29-2005
Registered User
 

Join Date: Jun 2005
Posts: 6
Null Characters

How do I get rid of null characters/strings in a unix text file. I need to use this in a script. When I use dev/null it puts null characters in my file and makes it larger. Please help
Reply With Quote
Forum Sponsor
  #2  
Old 08-29-2005
reborg's Avatar
Administrator
 

Join Date: Mar 2005
Location: Ireland
Posts: 3,590
What exactly do you mean, what are you using /dev/null for?

When I use it as a null device that exactly how it behaves:

Code:
user1@balrog ~
$ touch emptyfile

user1@balrog ~
$ ls -l emptyfile 
-rw-r--r--  1 user1 staff 0 Aug 30 01:15 emptyfile

user1@balrog ~
$ cp /dev/null emptyfile 

user1@balrog ~
$ ls -l emptyfile 
-rw-r--r--  1 user1 staff 0 Aug 30 01:15 emptyfile

user1@balrog ~
$ cat /dev/null > emptyfile 

user1@balrog ~
$ ls -l emptyfile 
-rw-r--r--  1 user1 staff 0 Aug 30 01:15 emptyfile
Reply With Quote
  #3  
Old 08-29-2005
Ygor's Avatar
Moderator
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,248
To remove nulls from a file...
Code:
sed 's/\x0//g' file1 > file2
Reply With Quote
  #4  
Old 01-13-2006
Registered User
 

Join Date: Jan 2006
Posts: 2
Question Replace Binary Nulls with spaces using Unix cmd

Hi,

We have an input datafile coming in from a different source. When this file is being processed by the Unix code on a AIX machine, it give a different record count and fails reconciliation with the expected couts. In short the Binary Nulls are getting treated differently when we are doing a processing of file. The main thing change is when we redirect the data from the input data file to another temporary file to remove the last line, which is a control record.

In this process the file that gets created as a totally different record length as the binary nulls are being treated differently by the unix.

Please advice.
Reply With Quote
  #5  
Old 01-13-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,269
MVS ignores nulls, UNIX does not - for example. You will have to change the "binary nulls" to spaces
Code:
sed 's/\x0/ /g' file1 > file2
Reply With Quote
  #6  
Old 01-13-2006
Registered User
 

Join Date: Jan 2006
Posts: 2
But this means that we are modifying inpur data, which is really not possible. If a binary null has come in a number field position then it will throw an error at oracle level.
But if we replace the binary Nulls with space then it will throw an error for invalid data.
And also if binary nulls is in a varchar field which is a unique constraint then space will be taken as a value and the wrong data will be entered.

I dont think replacing them with the space is not a good idea.

I saw another thread talkingabout the following command

perl -pi -e '$_ = "" if ($. == 1);' filename

All I need is to remove the last line of control record from the input file and go ahead.

Please let me know if this approach is right. Do you foresee any negative consequence?

Thx
Arch
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 09:47 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0