LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-11-2003, 04:02 AM   #1
pamide
LQ Newbie
 
Registered: Sep 2001
Location: Italy
Distribution: Mandrake
Posts: 8

Rep: Reputation: 0
Eliminare LF CR dal testo (fine riga Windows)


Ciao!
Devo creare un file testo (html) partendo da un file esistente e aggiungendo dati.
I file sono in una partizione FAT.
Quindi ho il file show.html in una partizione FAT che non ha il fine linea (^M) specifico dell'ambiente Win.
Faccio la copia nella mia directory ~miky (Linux)
cp show.html ~/tmp.html
Il file tmp.html non ha ancora i fastidiosi ^M
Adesso aggiungo testo:
echo " bla bla bla" >> tmp.html
A questo punto tutte le righe precedenti si ritovano con un ^M a fine riga.
Perche'?

Grazie,Miky
 
Old 12-11-2003, 05:12 AM   #2
BSlack
Member
 
Registered: Nov 2003
Location: Italy: 44° 42' N - 12° 11' E
Distribution: Slackware, what else?!!
Posts: 63

Rep: Reputation: 15
Quote:
Quindi ho il file show.html in una partizione FAT che non ha il fine linea (^M) specifico dell'ambiente Win.
...
Il file tmp.html non ha ancora i fastidiosi ^M
Sei sicuro??
Come sono stati creati i file sulla partizione FAT?
 
Old 12-11-2003, 06:11 AM   #3
MartinN
Member
 
Registered: Nov 2003
Location: Ronneby, Sweden
Posts: 555

Rep: Reputation: 30
It would have been slightly easier if you had written in English.

This is a wild guess , but maybe you want the commands dos2unix and unix2dos. They can convert a plain text file to get the CR/LF right.

Read
Code:
man dos2unix
and
Code:
man unix2dos
Good luck!
Martin
 
Old 12-17-2003, 03:20 AM   #4
pamide
LQ Newbie
 
Registered: Sep 2001
Location: Italy
Distribution: Mandrake
Posts: 8

Original Poster
Rep: Reputation: 0
Sorry!
I should have written in English! I didn't realise! Sorry!

The original file, show.html was created with a Windows text editor. So it has all that ^M to end every line.
Only that the new vi is too "smart" and doesn't show me the ^M if the file is a DOS file. My script processes it and I get a "Linux file". Now vi is "smart" again and shows me that dammed ^Ms.

My script:

cp show.html ~/tmp.html
echo "text lines" >> ~/tmp.html

Oooh! How I wish the old dumb vi!!
Anyhow it seems that the browser do like the file html in the DOS format,even if it's running under Linux!

Miky
 
Old 12-17-2003, 11:07 AM   #5
rkngl
LQ Newbie
 
Registered: Dec 2003
Location: Australia
Distribution: Mandrake 10
Posts: 18

Rep: Reputation: 0
vi autodetected line endings

Vi hid those ^M because it detected you were using Windows line endings.
Your problem is, when you run it through the script, you introduced a line that ends in LF, rather than the CR+LF that's used throughout the rest of your file. This made Vi think you were using linux line endings, so it decided to show those ^M again.If you want to get rid of them, make all the line endings either LF or CR+LF, but not a mix of both.
 
Old 12-30-2003, 04:05 AM   #6
pamide
LQ Newbie
 
Registered: Sep 2001
Location: Italy
Distribution: Mandrake
Posts: 8

Original Poster
Rep: Reputation: 0
Well, I need a DOS file! And this is because a browser likes it that way. It does not work properly if there are no CR+LF in the JavaScript code lines.

All I want is to get rid of that vi's option to show me whatever it likes!

Miky
 
Old 12-30-2003, 07:30 AM   #7
rkngl
LQ Newbie
 
Registered: Dec 2003
Location: Australia
Distribution: Mandrake 10
Posts: 18

Rep: Reputation: 0
As someone else said, use unix2dos to convert from CR line endings to CR+LF throughout a whole file. If you want vi to use dos line endings type :set ff=dos inside vi while in command mode.

BTW: If you use semi-colons(;) at the end of each statement in your javascript like you're supposed to, then you shouldn't have to worry about CR+LF's.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SVIDEO -> Composite messed up in X, fine in Windows? kleptophobiac Linux - Hardware 2 07-30-2004 09:20 AM
How to get ADSL working with RedHat9 - fine in Windows rylan76 Linux - Networking 6 06-20-2004 12:59 AM
X croaks at 640x480, but Windows works fine. Luke727 Debian 6 05-28-2004 06:19 PM
No internet access in linux, works fine in windows c0uchm0nster Linux - Networking 8 01-29-2004 06:45 AM
printer works fine in windows but is slow under linux nef Linux - Hardware 4 09-28-2003 02:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:59 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration