Link to home
Start Free TrialLog in
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?
SOLUTION
Avatar of serialband
serialband
Flag of Ukraine image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of richsark

ASKER

Thank you all.

I appreciate the quick turn around !
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).