473,395 Members | 1,948 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

removing ^m char

I have uploaded one txt file from windows to unix.when i am opening the file
in vi editor at the end of every line it is giving ^m char.

can any one tell me what is the procedure to remove ^m char from my txt file.

Regards
Anutosh
Jul 11 '08 #1
4 3752
Nepomuk
3,112 Expert 2GB
Well, you could just remove it with vi, but I'm guessing it's not only on this file or the file is very big?
In that case, you could try the following bash script:
Expand|Select|Wrap|Line Numbers
  1. while read line; do echo "${line%%^m}"; done < <(cat file.txt) > new_file.txt
(file.txt being your old file and new_file.txt being the new one)

Hope it works.

Greetins,
Nepomuk
Jul 11 '08 #2
mac11
256 100+
you probably have a utility called dos2unix on your unix machine which will do that for you

google found this summary page for me, but you can probably just run man for it yourself
http://linux.about.com/od/commands/l...l1_dos2uni.htm
Jul 11 '08 #3
you probably have a utility called dos2unix on your unix machine which will do that for you

google found this summary page for me, but you can probably just run man for it yourself
http://linux.about.com/od/commands/l...l1_dos2uni.htm
If you just want to do this while vi is open ...

You can just do this :

1. open file in vi
2. type this --> :%s/<Ctrl+V><Ctrl+M>// ----> then hit Enter

Where the <Ctrl+V> command is ... hold the Ctrl button and press the V key
and the same goes for the <Ctrl+M> command.

The <Ctrl+V> command will insert this character '^'
The <Ctrl+M> command will insert the 'M' character (which stands for a carraige return in dos)
Jul 11 '08 #4
gpraghuram
1,275 Expert 1GB
i think dos2unix is the best option for this.

Raghu
Jul 14 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Anthony | last post by:
Hi, Removing files seems to be rather clumsy in C (not C++). I am trying next piece of code to delete a file (under W32); int errno; errno = remove("FSelCancelled"); After exiting the...
12
by: Magix | last post by:
Hi, Everytime I received a fix-length of string, let say 15 (the unused portion will filled with Spaces before receive), I want to remove the Spaces from END until I encounter a non-space char....
6
by: becte | last post by:
I am little bit confused Is this a legal way of removing a substring from a string? What about the second alternative using strcpy, is it ok even though the source and dest. strings overlap? ...
24
by: Kunal | last post by:
Hello, I need help in removing if ..else conditions inside for loops. I have used the following method but I am not sure whether it has actually helped. Below is an example to illustrate what I...
2
by: almurph | last post by:
Folks, I have an array of chars nad would like to remove any repeating terms. Any ideas as how to do this? Thanks, Al.
6
by: bruce | last post by:
hi... i'm running into a problem where i'm seeing non-ascii chars in the parsing i'm doing. in looking through various docs, i can't find functions to remove/restrict strings to valid ascii...
16
by: junky_fellow | last post by:
Is there any efficcient way of removing the newline character from the buffer read by fgets() ? Is there any library function that is similar to fgets() but also tells how many bytes it read...
13
by: Mumia W. | last post by:
Hello all. I have a C++ program that can count the YOYOs that are in a grid of Y's and O's. For example, this Y O Y O O Y O Y O Y O O Y O Y Y O Y O Y O O Y O O Y Y O Y O
11
by: ramu | last post by:
Hi, Suppose I have a string like this: "I have a string \"and a inner string\\\" I want to remove space in this string but not in the inner string" In the above string I have to remove...
3
by: humsafar | last post by:
#include <iostream.h> #include <stdlib.h> #include <stdio.h> Class StudyProgram { Public: StudyProgram (); Void add StudyProgram (); Void edit StudyProgram (); Void delete StudyProgram ();
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.