Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Another problem..Please help..

Status
Not open for further replies.

fsanchez13

Technical User
May 9, 2003
35
US
Ok when I VI a file I see the following

23:59:41^M SECTION 12: TRUNK GROUP^M
ID TGNAME^M
50^M
51^M
52^M
53^M
ID IPC OPC OFL MTU USG ITUSG OTUSG^M
50 0 7 0 0 0 0 0^M
51 0 18 0 0 2 0 2^M
52 0 0 0 0 0 0 0^M
53 0 4 0 0 0 0 0^M
ID IPCTT OPCTT OFLTT SILC EAIPC EAITU FAOUT^M
50 0 7 0 0 0 0 0^M
51 0 18 0 0 0 0 0^M
52 0 0 0 0 0 0 0^M
53 0 4 0 0 0 0 0^M
ID IAMRC RELI INSVC OOS^M
50 0 0 64 0^M
51 0 0 2 0^M
52 0 0 1 0^M
53 0 0 1 0^M
^M
^M


But when I cat the same file I see it like:
SECTION 12: TRUNK GROUP
ID TGNAME
50
51
52
53
ID IPC OPC OFL MTU USG ITUSG OTUSG
50 0 7 0 0 0 0 0
51 0 18 0 0 2 0 2
52 0 0 0 0 0 0 0
53 0 4 0 0 0 0 0
ID IPCTT OPCTT OFLTT SILC EAIPC EAITU FAOUT
50 0 7 0 0 0 0 0
51 0 18 0 0 0 0 0
52 0 0 0 0 0 0 0
53 0 4 0 0 0 0 0
ID IAMRC RELI INSVC OOS
50 0 0 64 0
51 0 0 2 0
52 0 0 1 0
53 0 0 1 0


How do I get rid of all the ^M from the file? I need it to look like the VI version just without the ^M.
 
Those are carriage returns. Dos and windows typically use these to mark the end of a line. Unix/linux just uses a linefeed.

There are many methods to get rid of those ^M characters. Under SCO there is a utility called dtox and you would do it this way:
dtox oldfile > newfile

I think other unixes may have this but call it dos2unix or similar.

Since your file is small, you may just want to try this:

cat oldfile > newfile

and they should go away.
 
Thanks Hemo but the problem is this file is HUGE!! I only cut a small tid bit to show as well as when I cat the file it drops the Time Stamp that I need
 
ok, foot in my mouth.
cat oldfile > newfile
doesn't seem to kill the ^M characters on my unix box. Back to other methods.

dos2unix oldfile newfile

or even in vi you can do a global edit and get rid of those characters. Press : to get into edit mode, then enter the following
1,$s/^M//

and press enter. To enter the ^M in the edit line, first press Ctrl-v, and then press Ctrl-m. This will substitute blank space with the ^M starting at line 1 to the end of the file.
 
I tried the dos2unix and it works great. Thank you very much
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top