Removing ^@ chanracter fromthe end of Linux file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Removing ^@ chanracter fromthe end of Linux file
# 1  
Old 09-14-2009
Removing ^@ chanracter fromthe end of Linux file

Hi,

I have a Linux file which has content as shown below

2,Latest Event in RFP_EVENT match Lastest event in Source PRH_RQ_REQUEST,Failed
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@"1"|"RFP_MASTER

I am not sure what these characters are.. I was in an assumption that these are similar to COntol M characters in UNIX environment and tried using the command


perl -pi -e 's/^V^@/ /g' <file_name>

But this does not work. Could someone please help


Thanks,
Bhuvaneswari, S
# 2  
Old 09-14-2009
Can you please try with dos2unix command?
# 3  
Old 09-14-2009
^@ isn't two separate characters, but the representation of the null byte (ASCII code 0), which is usually used to terminate a string. You can remove it using
Code:
perl -i -pe 's/\0/ /g' <yourfile>

but I'd take a look as to why those are written to the file. For example, it's a common attack vector on web servers embedding a null byte in an URL to fool the parser.
# 4  
Old 09-14-2009
Thanks for the reply, I have tried with perl -i -pe 's/\0/ /g' <file_name>, it removed all the ^@ characters.

Thanks for the quick help.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Add words in beginning , end after removing a word in a file

My file has the entries like below... /dev/sds /dev/sdak /dev/sdbc /dev/sdbu I want to make the file like below echo 1 > /sys/block/sds/device/rescan echo 1 > /sys/block/sdak/device/rescan echo 1 > /sys/block/sdbc/device/rescan echo 1 > /sys/block/sdbu/device/rescan (2 Replies)
Discussion started by: saravanapandi
2 Replies

2. Linux

File conversion and removing special characters from a file in Linux

I have a .CSV file when I check for the special characters in the file using the command cat -vet filename.csv, i get very lengthy lines with "^@", "^I^@" and "^@^M" characters in between each alphabet in all of the records. Using the code below file filename.csv I get the output as I have a... (2 Replies)
Discussion started by: dhruuv369
2 Replies

3. UNIX for Dummies Questions & Answers

Removing empty lines at the end of a Tab-delimited file

I'm trying to remove all of the empty lines at the end of a Tab delimited file. They have no data just tabs. I've tried may things, here are a couple: sed /^\t.\t/d File1 > File2 sed /^\t{44}/d File1 > File2 What am I missing? (9 Replies)
Discussion started by: SirHenry1
9 Replies

4. UNIX for Dummies Questions & Answers

Removing characters from end of string

Hello, I have records like below that I want to remove any five characters from the end of the string before the double quotes unless it is only an asterik. 3919,5020 ,04/17/2012,0000000000006601.43,,0000000000000000.00,, 132, 251219,"*" 1668,0125 ... (2 Replies)
Discussion started by: jyoung
2 Replies

5. UNIX for Dummies Questions & Answers

Removing trailing lines at the end of a text file

How do you remove trailing empty lines at the end of a text file? Thanks! (3 Replies)
Discussion started by: evelibertine
3 Replies

6. UNIX for Dummies Questions & Answers

Removing end of line using SED

Hello Friends, How can I remove the last two values of this line using sed John Carey:507-699-5368:29 Albert way, Edmonton, AL 25638:9/3/90:45900 The result should look like this: John Carey:507-699-5368:29 Albert way, Edmonton, AL 25638 (3 Replies)
Discussion started by: humkhn
3 Replies

7. UNIX for Dummies Questions & Answers

Removing ^@ character at the end own belowof Linux file

Hi, I have a Linux file which has content as sh (0 Replies)
Discussion started by: bhuvanas
0 Replies

8. UNIX for Dummies Questions & Answers

removing a character and addending to end in each line in a file

HI i am having a file this (sys19:pnlfct:/pfact/temp>) cat temp_sand 1234567890 1234567890 1234567890 1234567890 I want to make this file as (sys19:pnlfct:/pfact/temp>) cat temp_sand 1456789023 1456789023 1456789023 1456789023 just take the 2nd and 3rd position and put it... (5 Replies)
Discussion started by: arunkumar_mca
5 Replies

9. Shell Programming and Scripting

Removing Space at the end of file

Hi.... I have a situation...I have a data file...that has space(an extra row with no data) at the end of file. I am trying to remove that spaces only if the file has a space at the end of file and if there is no space I don't want to do anything. Can you please help me in this regards. ... (4 Replies)
Discussion started by: rkumar28
4 Replies

10. Shell Programming and Scripting

Removing characters from end of $string

I am writing a script to search PCL output and append more PCL data to the end accordingly. I need to remove the last 88 bytes from the string. I have searched for a few hours now and am coming up with nothing. I can't use head or tail because the PCL output is all on one line. awk crashes on... (3 Replies)
Discussion started by: craig2k
3 Replies
Login or Register to Ask a Question