Find files which contain a null character


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Find files which contain a null character
# 1  
Old 12-14-2005
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 Smilie
# 2  
Old 12-14-2005
What do you mean NULL character here??
# 3  
Old 12-15-2005
Hi Mona,

I mean a Hex 00 character.

Cheers
Helen
# 4  
Old 12-15-2005
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 Smilie
# 5  
Old 12-15-2005
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.
# 6  
Old 12-16-2005
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 Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove first NULL Character in Flat File

We have a flat file with below data : ^@^@^@^@00000305^@^@^@^@^@^@430^@430^@^@^@^@^@^@^@^@^@09079989530As we can see ^@ is Null character in this file I want to remove only the first few null characters before string 00000305 How can we do that, any idea. I want a new file without first few... (5 Replies)
Discussion started by: simpltyansh
5 Replies

2. Shell Programming and Scripting

To find record having null value

Hi All My requirement is to find the null values in particular column of a file and reject it in case if it contains null values. But the challenge is that I want a common command which can be used across different file, as the position of the column we need to check for different file may get... (14 Replies)
Discussion started by: ginrkf
14 Replies

3. Shell Programming and Scripting

Find character and Replace character for given position

Hi, i want find the character '-' in a file from position 284-298, if it occurs i need to replace it with 'O ' for the position in the file. How to do that using SED command. thanks in advance, Sara (9 Replies)
Discussion started by: Sara183
9 Replies

4. UNIX for Advanced & Expert Users

Insertion of Null Character while writing into file

I have a huge file with record length around 5000 characters. There is an ETL tool datastage which is writing this data to the file(AIX server). At position 4095 i have seen NULL Character(^@). when i am using this command "head -1 file_nm | sed 's/\000//g'" --- the output is displaying... (3 Replies)
Discussion started by: issaq84mohd
3 Replies

5. Programming

Question about NULL Character & fgets()

Assume client send the message " Hello ", i get output such as Sent mesg: hello Bytes Sent to Client: 6 bytes_received = recv(clientSockD, data, MAX_DATA, 0); if(bytes_received) { send(clientSockD, data, bytes_received, 0); data = '\0';... (2 Replies)
Discussion started by: f.ben.isaac
2 Replies

6. Shell Programming and Scripting

need to find last character in each line in all files

Hi, I need to read each line in all files .If last character in each line is not ;(semicolon) then i need to append next line also.Here each line may consists of multiple semicolons(;).but i need to read only last character.I need to achieve this using shell script.And i need to remove tht last... (7 Replies)
Discussion started by: dbsurf
7 Replies

7. Shell Programming and Scripting

Null Character Handling

Hi All, I have a problem with Null values while reading line by line from a text file. I wrote a shell script to read set of file names from a text file line by line, and zipping the each individual file and copying those zip files into some separate directory, and removing the original file... (3 Replies)
Discussion started by: npk2210
3 Replies

8. UNIX for Dummies Questions & Answers

batch delete using find, files with # character

UPDATE: Sorry, disregard this. It did work, I made a mistake; I just shouldn't have been using maxdepth. I do think it is good to know, however, that find | grep '#' | xargs rm will "clean up" funnily named files in a directory. Of course, some of those funnily named files are there... (0 Replies)
Discussion started by: tphyahoo
0 Replies

9. UNIX for Advanced & Expert Users

sending a null character to a terminal

I'm testing out some ESMTP AUTH stuff, and it requires that the username and password be on the same line separated by a null character. Does anyone know how to echo the ASCII null character? Thanks, Alex (3 Replies)
Discussion started by: vertigo23
3 Replies

10. UNIX for Dummies Questions & Answers

GREP a string with NULL Character

Does anyone know how to use grep/egrep to find a string that contains a null character? i.e.: the string looks like this: null0001nullN well I want to be able to : grep '0001N' is there a wildcard character or something that I can put in the grep to include the nulls? (3 Replies)
Discussion started by: weerich
3 Replies
Login or Register to Ask a Question