Avatar of richsark
richsarkFlag for United States of America

asked on 

txt file all screwed up ^M and no carriage returns at each line

Hello Folks

I have a text file. I look at it using my Mac, I see that it has ^M everywhere

Looks like this:
conf    network delete  fixed   10.77.1.1 view default^Mconf    network delete  fixed   10.77.1.2 view default^Mconf    network delete  fixed   10.77.1.3 view default^Mconf

Open in new window


I need it to be Space delimited, not TAB and without the ^M's and I also need carriage returns after each line.

So... It should look like this:

conf	network	delete	fixed	10.77.1.2 view default
conf	network	delete	fixed	10.77.1.3 view default

Open in new window


Is there a shell script or even a perl script that I can fix this up?
PerlShell ScriptingProgramming

Avatar of undefined
Last Comment
wilcoxon
SOLUTION
Avatar of serialband
serialband
Flag of Ukraine image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
SOLUTION
Avatar of farzanj
farzanj
Flag of Canada image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of richsark
richsark
Flag of United States of America image

ASKER

Thank you all.

I appreciate the quick turn around !
Avatar of wilcoxon
wilcoxon
Flag of United States of America image

Another option is to open the file in vim and :set fileformat=unix.  If you don't have vim then you can open it in vi and do :%s%^M%^M%g (with both ^M being ctrl-V ctrl-M) - at least that replace works in vim.  I think the same replace should work in sed as well (though I always forget the switch to make sed do an inline edit).
Programming
Programming

Programming includes both the specifics of the language you’re using, like Visual Basic, .NET, Java and others, but also the best practices in user experience and interfaces and the management of projects, version control and development. Other programming topics are related to web and cloud development and system and hardware programming.

55K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo