Deleting UNIX End of Line Chachracter \000


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Deleting UNIX End of Line Chachracter \000
# 1  
Old 12-15-2004
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
# 2  
Old 12-15-2004
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

# 3  
Old 12-22-2004
found solution or not ???
let me now
# 4  
Old 12-22-2004
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

UNIX help adding data to end of a line with a variable

I am trying to add a date variable to the end of each line. This is what I have to start with cat ${DATAPATH}/Participate_Stream${STREAMDATE}.dryak1.csv | grep ^',' | awk '{print $0}' >> ${DATAPATH}/badparticipant.csv This is what I tried $DATE is a variable I have defined. cat... (3 Replies)
Discussion started by: req62861
3 Replies

2. UNIX for Dummies Questions & Answers

Deleting a pattern in UNIX without deleting the entire line

Hi I have a file: r58778.3|SOURCES={KEY=f665931a...,fw,221-705}|ERRORS={16_1:T,30_1:T,56_1:C,57_1:T,59_1:A,101_1:A,115:-,158_1:C,186_1:A,204:-,271_1:T,305:-,350_1:C,368_1:G,442_1:C,472_1:G,477_1:A}|SOURCE_1="Contig_1092402550638"(f665931a359e36cea0976db191ff60ff09cc816e) I want to retain... (15 Replies)
Discussion started by: Alyaa
15 Replies

3. UNIX for Dummies Questions & Answers

Confusion with CRLF (wint) and LF (unix) as end of line seperators

I know that windows uses CRLF as a end of line character while Unix uses LF. But visually i could not see any difference in files while creating on either of plat forms. CR (Carriage Return) means to bring cursor to beginning of line while LF (Line feed) means to bring cursor to next line... (5 Replies)
Discussion started by: sarbjit
5 Replies

4. Shell Programming and Scripting

Replacing end of line with " in a UNIX file

How should I replace End of line Character by ". i.e in a file - Name1,NO1 Name2,No2 Name3,No3 .... Should look like -- Name1,NO1" Name2,No2" Name3,No3" .... (2 Replies)
Discussion started by: The Observer
2 Replies

5. UNIX for Advanced & Expert Users

Deleting end of line $ character in file

Hi, I've got a file where in the middle of the record is a $ end of line character, visible only when I open the file in vi and do :set list. How to I get rid of the character in the middle and keep it at the end. The middle $ character always appears after SW, so that can be used to tag it.... (3 Replies)
Discussion started by: bwrynz1
3 Replies

6. UNIX Desktop Questions & Answers

Deleting Junks at the end of each line in a file

Is there any way to delete the Junk Characters(Invalid Characters like ^,',",),(,&,# etc.,) at the end of each record in a file? I want to do this using a single line script. Thanks to all in advance!!! (5 Replies)
Discussion started by: dave_nithis
5 Replies

7. UNIX for Dummies Questions & Answers

How to convert ^M appearing at end of line to unix newline?

How to convert ^M appearing at end of line to unix newline? As I have tried with ^M in 'tr' it replaced ^ to a newline. Thanks in advance. (21 Replies)
Discussion started by: videsh77
21 Replies

8. Shell Programming and Scripting

Deleting end line spaces for along file

How can i clear all space characteres for a long file at the end of each line? (3 Replies)
Discussion started by: osymad
3 Replies

9. Shell Programming and Scripting

windows file to unix :end line chararcter

hi , When i ftp a text file from Windows to unix enviornment and open the file in " vi editor" the end line charcrter of the windows file is seen as "cntrl+M" charcter in the Unix enviornment. Is there any command in unix , so that i dont see this "cntrl+M" chararcter in the... (9 Replies)
Discussion started by: dharmesht
9 Replies
Login or Register to Ask a Question