Jump to content

getting rid of ^B


tvlad
 Share

Recommended Posts

If i edit a file in windows, and then copy it to linux, if it's a script or smth like that it won't run.When i do vim -b on the file, i find that on every line it has ^B.

 

Now, there must be a way to get rid of those ^B.Is there a windows utility, or

should i do it in linux (it can be done, but how ? ) :D

Link to comment
Share on other sites

First, it isn't ^B, it's ^M.

 

#^M

# Log:^M

#^M

# 0.77s - Changed the default block behavior to REJECT not DROP^M

# 0.76s - Added a comment about the OPTIONAL WWW ruleset and a comment^M

# where to put optional PORTFW commands^M

# 0.75s - Added clarification that PPPoE users need to use^M

 

And i tryed using that sed command on this file, but no change (ofcourse i pu ^M instead of ^B in the command, ain't THAT dum ).

Link to comment
Share on other sites

First, it isn't ^B, it's ^M.

 

#^M

# Log:^M

#^M

#   0.77s - Changed the default block behavior to REJECT not DROP^M

#   0.76s - Added a comment about the OPTIONAL WWW ruleset and a comment^M

#           where to put optional PORTFW commands^M

#   0.75s - Added clarification that PPPoE users need to use^M

 

And i tryed using that sed command on this file, but no change (ofcourse i pu ^M instead of ^B in the command, ain't THAT dum ).

 

Well you said ^B, didn't you?

 

the way to type ^M is "ctrl-v ctrl-ENTER", it isn't obvious, is it? so no you aren't dumb :D

 

Do it again with sed

 

or if you prefer vim, use the command ":%s/^M//g"

Link to comment
Share on other sites

Thx Bvc, though i'm wandering, couldn't it be done with awk, sed or some other very common tools ????

Ofcourse! The way I showed you works, I've done it dozens of times! :shock:

 

with sed:

~$ sed 's/^M//g' file.dos > file.unix

 

with awk:

~$ awk 'gsub("^M","")' file.dos > file.unix

 

with vi (edits directly the file):

~$ vim -c ':%s/^M//g 

:wq

' file.dos

 

Isn't that enough!

 

Remember '^M' is -------> 'ctrl-v ctrl-ENTER'

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...