how to get rid of ^M in the file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to get rid of ^M in the file
# 1  
Old 05-19-2009
how to get rid of ^M in the file

Hi
I have a file wich contains ^M characters, looks like these are from DOS,
Is there a way to get rid of them? Thanks -A
# 2  
Old 05-19-2009
after that many posts you have, you should know how to search the forum. this question is asked many times. at the search box, type ^M and you can see similar threads like this.
# 3  
Old 05-19-2009
You can use the utility dos2unix or:

Code:
tr -d '\r' < file > newfile

Regards
# 4  
Old 05-19-2009
Thanks a lot, Franklin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

CDE, annoying file manager window. How to get rid of that

Hello, CDE workspace. How to get rid of annoying popping up file manager window which appears every time after logging in. For example.any suggestions, I would be appreciate. (3 Replies)
Discussion started by: wolfgang
3 Replies

2. Red Hat

How to change name to get rid of name in front of file names?

admin.campaign.sql admin.cardnumber_filter.sql understand that rename is using mv command but how do I rename such that it become the following: campaign.sql cardnumber_filter.sql thanks (2 Replies)
Discussion started by: jediwannabe
2 Replies

3. UNIX for Dummies Questions & Answers

Any way to get rid of ^M characters in a text file using pr?

When I use vi to see what's in the file I get this: int add1(int x) {^M return x + 1;^M} ^Mint subtract1(int x) {^M return x - 1;^M} ^Mint double_it(int x) {^M return x * 2;^M} ^Mint halve_it(int x) {^Mreturn x / 2;^M} ^Mint main() {^M int myint;^M int result;^M ... (2 Replies)
Discussion started by: Nonito84
2 Replies

4. Shell Programming and Scripting

get rid of "^" character in a .txt file

I have a file that I ran the dos2unix utility on, it cleans up pretty well, but I noticed an occasional ^M leftover, (actual characters) these may or may not be strays from my original dos file. Either way, I want to get rid of the ^ and any character that may follow. ^M ^C or whatever. How do I... (6 Replies)
Discussion started by: ajp7701
6 Replies

5. Shell Programming and Scripting

How to get rid of cannot remove file error in bash script?

Hi Guys, I am creating a couple of temp. files in a script. After completing the script, I am using the rm command to delete these files. The files are getting deleted but I am getting "filename - cannot find file;no such file or directory" error in my bash shell terminal window. I am using... (3 Replies)
Discussion started by: npatwardhan
3 Replies

6. Shell Programming and Scripting

Getting rid of a field in a big file - Urgent

Hi Unix Gurus, I have a file with 100,000 lines with lines in the format: 1,35518,35518,1,2,1,72,1253889535,1253889775,240,30,152.163.141.8,US,0,00,-g 1253888723-g 1253889445 1,78973,78973,1,2,2,91,1253889535,1253889775,240,30,152.163.141.8,US,0,00,-g 1253888723-g 1253889445... (3 Replies)
Discussion started by: toms
3 Replies

7. UNIX for Dummies Questions & Answers

How to get rid of ^[[D

Hi All, Im selecting a large record from a table and putting it in a file in the unix box. The file has a hidden character "^[[D " present in it. Can any one help me in getting rid of the character Thanks in advance, (4 Replies)
Discussion started by: madhan@29
4 Replies

8. Shell Programming and Scripting

How can I get rid of the ` character from input file?

A sed command works most of the time however it fails sometimes. I put each line (record) I read of a file through the following command data=$(cat file | sed 's///g' | sed 's|.*ex:Msg\(.*\)ex:Msg.*|\1|' ) When I run the script I get a message that states that there is an invalid format... (6 Replies)
Discussion started by: gugs
6 Replies

9. UNIX for Advanced & Expert Users

Get rid of junk character in a file

I have a file with one of the following lines, when opened with vi 33560010686GPT£120600GBPGBP10082007DS In the above line, I want to get rid of the junk character before the £ (pound sysmbol). When I tried copying £ from windows and copy in unix vi, it prints as £ and I tried pattern replace... (2 Replies)
Discussion started by: nskworld
2 Replies

10. Shell Programming and Scripting

how to get rid of blank line in a flat text file

Hi, I have a flat text file which contains blank line between each text line. Is there any command to get rid of it? Thanks for your help (11 Replies)
Discussion started by: xfang
11 Replies
Login or Register to Ask a Question