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 > 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
need to find last character in each line in all files dbsurf Shell Programming and Scripting 7 01-24-2008 09:35 AM
Null Character Handling npk2210 Shell Programming and Scripting 3 09-29-2007 04:51 AM
Replacing character in file with null value HLee1981 Shell Programming and Scripting 18 07-18-2006 01:33 PM
batch delete using find, files with # character tphyahoo UNIX for Dummies Questions & Answers 0 05-30-2006 12:05 PM
sending a null character to a terminal vertigo23 UNIX for Advanced & Expert Users 3 09-30-2005 09:58 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-14-2005
Bab00shka Bab00shka is offline
Registered User
  
 

Join Date: Apr 2002
Location: Chesterfield, UK
Posts: 123
Find files which contain a null character

Hi,

I would like to use grep to find files which contain NULL characters. I'm not sure how to represent the null character in the grep statement.

Could anyone help please?

Thanks!
Helen
  #2 (permalink)  
Old 12-14-2005
mona's Avatar
mona mona is offline
Registered User
  
 

Join Date: Nov 2005
Location: Singapore
Posts: 96
What do you mean NULL character here??
  #3 (permalink)  
Old 12-15-2005
Bab00shka Bab00shka is offline
Registered User
  
 

Join Date: Apr 2002
Location: Chesterfield, UK
Posts: 123
Hi Mona,

I mean a Hex 00 character.

Cheers
Helen
  #4 (permalink)  
Old 12-15-2005
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
I merged your threads. The trouble is that sed is using strings. My sed man page explicitly states: "It cannot edit binary files or files containing ASCII NUL (\0) characters or very long lines." Same with grep.
  #5 (permalink)  
Old 12-15-2005
Bab00shka Bab00shka is offline
Registered User
  
 

Join Date: Apr 2002
Location: Chesterfield, UK
Posts: 123
Octal or hex in sed

Hi,

Is it possible to use octal or hex in sed?

The problem I have is that I need to replace a NULL character (ie hex 00 or octal 000) with the string "NULL_CHARACTER".

tr would only replace the null character with one correstponding character. I would need to replace the null with a string of characters as above.

Many thanks
Helen
  #6 (permalink)  
Old 12-16-2005
Bab00shka Bab00shka is offline
Registered User
  
 

Join Date: Apr 2002
Location: Chesterfield, UK
Posts: 123
We managed to get around the problem in the end.

So for future reference:

we used od -b to turn the file into octal format. We then did a grep for " 000" in the file (note space before 000). This confirmed the file had a null character.

Just finding files with the null character was sufficient - we didn't look any further into replacing the null character.

Cheers
Helen
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 12:13 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