The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
replace space by _ ruben.rodrigues Shell Programming and Scripting 6 01-21-2009 11:27 AM
Replace NULL with space pukars4u UNIX for Dummies Questions & Answers 1 06-22-2008 05:15 AM
How to compare null and space using single if condition jayakumarrt UNIX for Dummies Questions & Answers 3 05-16-2008 05:13 AM
replace a complex string with null fed.linuxgossip Shell Programming and Scripting 3 02-12-2008 06:13 PM
Replace 3 fields with null in the file vukkusila Shell Programming and Scripting 1 09-12-2007 01:10 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-06-2009
rikxik's Avatar
rikxik rikxik is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 250
Cannot replace null with space

I have a fixed width text file which has some null characters in no particular order. I need to replace them with spaces so that the width remains same.

I tried this:

Code:
tr  "\000" "\040" < mainfile > newfile
Does not work. I tested that it works the other way round:
Code:
$ echo "hello" |tr "l" "\000" > b
$ less b
he^@^@o
So tr is able to convert to null but cannot convert back from it. I have tried the typical sed/awk commands w/o any results. The null control characters are visible only when I use utilities like less/vim etc.

Any ideas?
  #2 (permalink)  
Old 03-06-2009
rikxik's Avatar
rikxik rikxik is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 250
[SOLVED] Cannot replace null with space

perl did it for me:

Code:
perl -pe 's/\000/ /g' oldfile > newfile
Seems like sed on Solaris suffers from this specific issue.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:59 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0