How to convert a .log file into .txt file under unix??


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to convert a .log file into .txt file under unix??
# 1  
Old 06-03-2009
How to convert a .log file into .txt file under unix??

Hi Friends,

I have a .log file generated from a tool(Windows PC) which can be opened using a notepad, but when I tried to view the file in unix (cygwin on my laptop) the file type is showing as binary file, So I am unable to process the file.
I need to extract some of the selected text from the file using grep. Can any one help me to solve this problem by providing the script to convert this file to .txt file in unix itself to avoid the time waste in opening the file in windows and saving it as .txt and opening it unix and processing it further.

Find my file in the attachment. I have hundreds of file like this.
Any help in this regard is highly aprreciable.
Thanks..

-----Post Update-----

I just renamed the file to .txt extension as I am unable to upload in this forum. Don't get confuse with this. It is originally a .log extension file.
# 2  
Old 06-03-2009
I don't have problem opening it in cygwin. Looks like your file is messed up - a null character is inserted every other position (od -c File1.txt). I think the file was not generated properly.

Note, unix doesn't have the concept of file extensions. All it cares about is what is inside. Also windows and unix handle line breaks differently (windows uses 2 characters, unix 1), so you can't just copy directly a text file b/w the two. If using ftp, you'll need to use ascii mode so it will take care the conversion for you. Or, you can use the command dos2unix to convert the wrongly transfered windows text file to unix format on unix.

-----Post Update-----

tr -sd '\0' '' < File1.txt > newfile

That is how to get rid of the null characters.

To convert it to true unix format,

dos2unix newfile

-----Post Update-----

tr -sd '\0' '' < File1.txt > newfile

That is how to get rid of the null characters.

To convert it to true unix format,

dos2unix newfile
# 3  
Old 06-03-2009
Open it in Write or change it to a .wri extension. Notepad's not smart enough to handle hex 0d chars.
# 4  
Old 06-04-2009
Thanks wireonfire. The solution suggested by you using "tr" command satisfied my requirement..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Convert a txt file to a CSV file

Hi , I have a Txt file which consist of 1000's of SOAP request and response and i want the file to be converted to a csv file like column a should have a soap request and column b should have the soap response . can someone assist me in achieving this please ? Thanks (2 Replies)
Discussion started by: kumarm8
2 Replies

2. Solaris

How to convert pdf file to txt?

Hello Unix gurus, I am learning unix. I have lots pdf data files. I need to convert them into txt files. Can you please guide me how to do that? Thanks in advance. Rao (1 Reply)
Discussion started by: raopatwari
1 Replies

3. Shell Programming and Scripting

Need to convert output.txt into html file

I have output.txt file generated through shell scripts which need convert in tabular format using html can you please help me output.txt Token State Date1 Date2 Description Name 34567 open 27/06/13 28/06/13 ... (5 Replies)
Discussion started by: vijay_rajni
5 Replies

4. UNIX for Dummies Questions & Answers

Cannot convert this .pages file to a .txt file?!?

I'm trying to use the textutil feature in terminal to convert this .pages file to a .txt file. I've succeeded converting other files like .doc or .docx over to a .txt but this one in particular is giving me headache. I changed the permission rights to 755 but I don't think that mattered to begin... (1 Reply)
Discussion started by: syregnar86
1 Replies

5. UNIX for Advanced & Expert Users

Convert delimiter to string in txt file

Hi, I need to convert tab delimiter to #*# in txt file. Does anybody know how to do it? If i'm using: tr -s '\t' '#*#' < name.txt > name_new.txt It converts only to #, but I need 3 chars. Thanks a lot. (2 Replies)
Discussion started by: borsud
2 Replies

6. Shell Programming and Scripting

How to convert a txt file to xml file

Hello, I donot have exact lenght of the file. But i want entire txt of the file to send it into one node. for example I have txt file.. asdfghjklmnbvcxzqwertyuiop., nswwneikniniwn so i need the output as <documentbody>asdfghjklmnbvcxzqwertyuiop., ... (9 Replies)
Discussion started by: Hemantgupta84
9 Replies

7. Shell Programming and Scripting

PERL:How to convert numeric values txt file to PACKED DECIMAL File?

Is there any way to convert numeric values txt file to PACKED DECIMAL File using PERL. Regards, Alok (1 Reply)
Discussion started by: aloktiwary
1 Replies

8. UNIX for Dummies Questions & Answers

To convert a txt file to .xls file

i want to convert a comma seprated file into a .xls file the file contains 3 fields seprated by a comma. i want to convert it into a .xls file with 3 columns and 37 rows DPRPT400,01/15/2009-15:03:06,01/15/2009-15:03:08 DPRPT401,01/15/2009-15:03:15,01/15/2009-15:03:32... (11 Replies)
Discussion started by: manit
11 Replies

9. Shell Programming and Scripting

convert a txt file to xls file

How to convert a txt file(tab delimiter) to xls file. Looking forward help. Thanks, Venkatesh. (2 Replies)
Discussion started by: venkatesht
2 Replies

10. UNIX for Dummies Questions & Answers

How to convert PS files to txt file?

Hi, I need to convert PS files to txt file. I thought of using ps2ascii, but its not installed in my AIX box, any other option? (2 Replies)
Discussion started by: redlotus72
2 Replies
Login or Register to Ask a Question