LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 05-01-2006, 04:16 AM   #1
olspookishmagus
LQ Newbie
 
Registered: Dec 2004
Posts: 10

Rep: Reputation: 0
Question Changing file-type of a text file


Greetings, especially to the linuxquestions.org regulars.

Here is the story:

I downloaded a book which consisted of many text files, one file for each chapter, and saved them all in one directory. When I navigated to the folder using the Nautilus file manager, throught GNOME, when I double-clicked on the first chapter file CHAP1.TXT it did not open while the second chapter, and all others, open in the GEdit (the default GNOME text editor).

I opened a console window and when I tried to view the files using cat there were no obvious problem. Then I thought I should use the file command to see if there is any problem. And here follows the output:

Code:
olspookishmagus@debian-sarge:~/linux_guides/foo_book$ file CHAP1.TXT
CHAP1.TXT: ISO-8859 English text, with CRLF, CR line terminators
olspookishmagus@debian-sarge:~/linux_guides/foo_book$ file CHAP2.TXT
CHAP2.TXT: ASCII English text, with CRLF, CR line terminators
And here is the question:
How I could, if I can alter the filetype of CHAP1.TXT so that it can match the others plus I can open it with GEdit?

Thought, it is irrelevant here is my system set-up:
Debian 3.1 (Sarge), GNOME

I hope this is not an inappropriate section and
thanks in advance.
 
Old 05-01-2006, 07:43 AM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
No need to make it so difficult. You can open the file directly in a text editor, the only problem is that GNOME doesn't seem to recognize it as a text file, right? So what I would do is simply open it up in gedit or another editor (using filepen) and save the contents to a new text file. If the new file is recognizable, problem solved.

Actually, even easier: 'cat CHAP1.TXT > CHAP1-fixed.TXT'.
 
Old 05-03-2006, 12:21 AM   #3
olspookishmagus
LQ Newbie
 
Registered: Dec 2004
Posts: 10

Original Poster
Rep: Reputation: 0
Well, I tried both the approaches you suggested and there was little success as to achieve the desired result. A file whose file-type would match all the other files of the group, to be more accurate an ASCII English text, with CRLF, CR line terminators file.

Your second suggested approach, the one using cat while redirecting output to a new file did the same thing as if I had used a cp command, and allow me to explain myself. The following two commands seem that the do the same:

Code:
olspookishmagus@debian-sarge:~/linux_guides/foo_book$ cat CHAP1.TXT > CHAP1-FIXED.TXT
olspookishmagus@debian-sarge:~/linux_guides/foo_book$ cp CHAP1.TXT CHAP1-FIXED.TXT
As for the first suggested approach, it has some result but not the desired one. I used GEdit to open the file but when I saved the file it was now in an UTF-8 encoding/format.

Isn't there a way to make the desired file of an ASCII English text, with CRLF, CR line terminators filetype?
To what do these filetypes differ?

And, but of course, thanks for the answer!
 
Old 05-03-2006, 01:00 AM   #4
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
Ah, I missed the ascii part. I just thought it was a bad file or something. Because it's really odd that your system isn't recognizing file as text in the first place. iso-8859 is a perfectly legitimate text encoding, indeed probably the most common one out there. YOu might check your gnome file association settings and see if there's something not set right.

I don't know where it is in gedit, but most text editors have a character encoding option somewhere where you can select the encoding. The one I use, kwrite, has it. ISO-8859 and UTF-8 are both ascii compatible, so there shouldn't be too much trouble in translation. Your only problem might be some punctuation marks. There are also some command line tools, iconv for one, that can convert files to other encodings.

Actually, now that I think about it, I don't even know if there is a straight ascii choice. Nearly everyone uses UTF-8 or some form of ISO encoding these days.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
changing "file type" designation dpn48312 Linux - General 4 02-26-2006 05:42 AM
changing line in text file tescik80 Programming 13 02-20-2006 05:43 AM
Changing coding of text file(LF -> CRLF) koyi Linux - General 2 10-18-2005 07:44 AM
Changing the default file type icons in gnome on fedora C3 Sm1ler Linux - General 3 04-22-2005 10:43 AM
open file, file of type selections rkfb Linux - Newbie 2 11-19-2003 05:32 AM


All times are GMT -5. The time now is 05:59 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration