LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 11-08-2004, 08:33 AM   #1
philipina
Member
 
Registered: May 2003
Posts: 77

Rep: Reputation: 15
Problem when inserting a new line in a file by using redirection.


Hello,

I use the following command to insert a line at the end of a file.

echo "My sentence" >> myFile

After the execution of this line if I open "myFile" with vi I can see the caracter "^M" in blue at the end of each existing line.
How can I avoid that problem?

Thanks in advance.

Alain.
 
Old 11-08-2004, 09:37 AM   #2
LasseW
Member
 
Registered: Oct 2004
Distribution: Fedora 7, OpenSuse 10.2
Posts: 108

Rep: Reputation: 15
Was this a Windows file originally ? The ^M is a carriage return character, used in DOS but not in native Unix text files. Anyway, you can get rid of them like this:

tr -d "\015" <My_file >My_new_file
 
Old 11-09-2004, 01:07 AM   #3
philipina
Member
 
Registered: May 2003
Posts: 77

Original Poster
Rep: Reputation: 15
Thank you it works fine.

Alain.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ text file line by line/each line to string/array Dimitris Programming 15 03-11-2008 08:22 AM
Autorun a .html file on inserting a DVD ilhbutshm Linux - Software 10 04-20-2005 11:07 AM
Perl: Inserting new data into the middle of a file R00ts Programming 5 03-07-2005 06:48 PM
inserting the data thru php in a text file suchi_s Programming 5 02-02-2005 03:28 AM
inserting text into a file DavidPhillips Programming 5 08-15-2003 04:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:14 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