The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Deleting end of line $ character in file bwrynz1 UNIX for Advanced & Expert Users 3 01-08-2008 09:17 AM
Deleting lines above a certain line eltinator Shell Programming and Scripting 3 10-11-2007 11:29 AM
Deleting First Two Characters On Each Line scotbuff Shell Programming and Scripting 5 12-15-2006 09:03 PM
Checking the last line and deleting srivsn Shell Programming and Scripting 3 12-13-2005 10:04 AM
Deleting end line spaces for along file osymad Shell Programming and Scripting 3 02-23-2005 09:56 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-15-2004
Registered User
 

Join Date: Mar 2002
Posts: 6
Deleting UNIX End of Line Chachracter \000

Hi,
I have this file which has some octal NULL characters (\000). I need to replace these characters with an ASCII NULL.

I've tried using Perl, the UNIX tr command..

History of this
I received a COBOL generated file, ran the od command to convert to a xxx byte per record file.

Now, some of the records that have octal NULLS wont convert and it merges the next line to this record with the current line. I found this at
http://www.canberra.edu.au/~sam/whp/sed-tricks.html

Type in a text file named "f127.TR" with the line starting tr above. Print the file on screen with cat f127.TR command, replace "filein" and "fileout" with your file names, not same the file, then copy and paste the line and run (execute) it. Please, remember this does not solve Unix end-of-file problem, that is the character '\000', also known as a 'null', in the file. Nor does it handle binary file problem, that is a file starting with two zeroes '\060' and '\060' http://www.canberra.edu.au/~sam/whp/sed-tricks.html

Any idea how I could do this in UNIX without using C or a different programming language.

Thanks,
U
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 12-15-2004
Ygor's Avatar
Moderator
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,243
not sure what the difference is between a null character and an ascii null. Perhaps you mean the space character. Anyway, tr can translate any char to another...
Code:
$ printf "a\000\n">file1
$ printf "b\000\n">>file1
$ od -hc file1
0000000 0061 620a 0a00
          a  \0  \n   b  \0  \n
0000006
$ tr '\0' ' ' < file1 > file2
$ od -hc file2
0000000 2061 620a 0a20
          a      \n   b      \n
0000006
Reply With Quote
  #3 (permalink)  
Old 12-21-2004
Registered User
 

Join Date: Dec 2004
Posts: 3
found solution or not ???
let me now
Reply With Quote
  #4 (permalink)  
Old 12-22-2004
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,454
An ascii null is represented by octal \000 so your question is senseless. Your reference that you quoted even mentions this:
the character '\000', also known as a 'null'

So you want to convert \000 to nulls? Good news! You're done.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 11:33 PM.


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 Global Fact Book

Content Relevant URLs by vBSEO 3.2.0