Hex editing


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Hex editing
# 1  
Old 12-07-2007
Question Hex editing

Hi,
I am new to UNIX. I have a text file where each line ends on the hexadecimal character "0A". In the file there are some records that contain the Hex characters "0D0A" which I need to replace by Hex "20".

Is there a simple way to do this?

Regards,
Swanie
# 2  
Old 12-07-2007
From the top
0A = newline character which is expected in unix text files
0D0A = DOS or windows textfile cr/lf

Changing the cr/lf to 20 is the same as joining the line beneath the cr/lf line to the cr/lf line. Is that what you really want: appending lines?

dos2ux (or dos2unix) is a utility that will get rid of DOS carriage return/linefeed characters and make them standard newlines.
# 3  
Old 12-08-2007
dos2ux

Hi Jim,
Thank you for responding. That is exactly what I want to do, join the line with the CR/LF to the next line. I am using NCR UNIX which does not appear to have the utility you mention:

# man dos2ux
ERROR: Manual entry does not exist for page dos2ux
# man dos2unix
ERROR: Manual entry does not exist for page dos2unix
#

Is there any other way?

Regards,
Swanie

Last edited by Swanie; 12-08-2007 at 12:16 AM.. Reason: Misspelling
# 4  
Old 12-08-2007
If you really want to convert CRLFs to a space and your file does not contain the string "@@", the following should work

Code:
 tr "\r\n" "@@" < infile | sed 's/@@/ /g'  > outfile

If "@@" is present in your file, you can substitute another unique string to achieve the same result
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert vi editing to text editing

Dear Guru's I'm using Putty and want to edit a file. I know we generally use vi editor to do it. As I'm not good in using vi editor, I want to convert the vi into something like text pad. Is there any option in Putty to do the same ? Thanks for your response. Srini (6 Replies)
Discussion started by: thummi9090
6 Replies

2. Shell Programming and Scripting

How to replace with "sed" some hex values by other hex values?

Assume I have a file \usr\home\\somedir\myfile123.txt and I want to replace all occurencies of the two (concatenated) hex values x'AD' x'A0' bytwo other (concatenated) hex values x'20' x'6E' How can I achieve this with the gnu sed tool? Additional question: Is there a way to let sed show... (1 Reply)
Discussion started by: pstein
1 Replies

3. UNIX for Dummies Questions & Answers

How to specify a FS as HEX value in AWK

Hi All, I have one input file seperated with Hex decimal B1 value. And i want to process this file. And iam creating an awk script to process this file. How can I specify the Field seperator as HEX B1 in my awk. Please help. Thanks in advance.:) (2 Replies)
Discussion started by: psk_kumar
2 Replies

4. Programming

What is the difference between ios::hex and std::hex?

Hi, Is there really a difference between these two, std::hex and ios::hex?? I stumbled upon reading a line, "std::ios::hex is a bitmask (8 on gcc) and works with setf(). std::hex is the operator". Is this true? Thanks (0 Replies)
Discussion started by: royalibrahim
0 Replies

5. Programming

ascii to hex

Hello guys, i want to convert a text file to hex and have written this code : int main(int argc, char **argv) { ifstream file; string fileName = "CODEZ"; file.open(fileName.c_str()); // oeffen im Text-Modus if(file) {... (5 Replies)
Discussion started by: Kingbruce
5 Replies

6. Programming

After converting the hexstr to Hex and storing the Hex in a char*

Hi All, My main intension of is to convert the Hexstring stored in a char* into hex and then prefixing it with "0x" and suffix it with ',' This has to be done for all the hexstring char* is NULL. Store the result prefixed with "0x" and suffixed with ',' in another char* and pass it to... (1 Reply)
Discussion started by: rvan
1 Replies

7. Shell Programming and Scripting

Hex Conversion

I need to have my scripts import volume groups and mknod devices files. I have most of the script working but the device file needs to be in the format 0x??0000 (where the question marks are my HEX representations of the volume group number. I have the code below and the output it produces which... (2 Replies)
Discussion started by: insania
2 Replies

8. Shell Programming and Scripting

Looking for a hex character?

Hi guys , i would want to count the concurrences of the 0A hex char in a text file , then if no matches i need to add a 0A at the end of the line. Any ideas? thx.Regards (1 Reply)
Discussion started by: Klashxx
1 Replies

9. UNIX for Advanced & Expert Users

Modifying binary file by editing Hex values ?

Hi , i'm using special binary file (lotus notes) and modifying an hexadecimal address range with windows hex editor and it works fine ! The file is an AIX one and i'm forced to transfert (ftp) it before modifying it and re-transfert ! NOW i would do this directly under AIX ! I can... (4 Replies)
Discussion started by: Nicol
4 Replies

10. UNIX for Dummies Questions & Answers

Ascii To Hex

How will I display on screen a UNIX ascii file with its HEX equivalent. I want to check whether 0D 0A is coming at the end of the file which I am generating from UNIX. (1 Reply)
Discussion started by: augustinep
1 Replies
Login or Register to Ask a Question