Avatar of richsark
richsark
Flag 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

8/22/2022 - Mon
SOLUTION
serialband

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER CERTIFIED SOLUTION
ozo

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
richsark

ASKER
Thank you all.

I appreciate the quick turn around !
wilcoxon

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).
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy