tvlad Posted May 20, 2003 Report Share Posted May 20, 2003 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 Quote Link to comment Share on other sites More sharing options...
tyme Posted May 20, 2003 Report Share Posted May 20, 2003 what are you using to edit the file in windows? Quote Link to comment Share on other sites More sharing options...
Cannonfodder Posted May 20, 2003 Report Share Posted May 20, 2003 You probably just need to convert the carriage returns from windows to linux.. Quote Link to comment Share on other sites More sharing options...
tvlad Posted May 20, 2003 Author Report Share Posted May 20, 2003 Yup, but how do i do that ??? Quote Link to comment Share on other sites More sharing options...
aru Posted May 20, 2003 Report Share Posted May 20, 2003 ~$ sed 's/^B//g' yourfile > yournewfile enter "^B" by typing "ctrl-v ctrl-b" Quote Link to comment Share on other sites More sharing options...
tvlad Posted May 20, 2003 Author Report Share Posted May 20, 2003 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 ). Quote Link to comment Share on other sites More sharing options...
tyme Posted May 20, 2003 Report Share Posted May 20, 2003 you could always use a text editor in linux that has a replace feature (such as gedit) and change ever ^M to an empty space...assuming the ^M shows up in the editor. Quote Link to comment Share on other sites More sharing options...
tvlad Posted May 20, 2003 Author Report Share Posted May 20, 2003 There must be a way to do it from text mode. Quote Link to comment Share on other sites More sharing options...
aru Posted May 20, 2003 Report Share Posted May 20, 2003 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" Quote Link to comment Share on other sites More sharing options...
tvlad Posted May 20, 2003 Author Report Share Posted May 20, 2003 Nope, doesn't work, all i want to do is to remove those ^M from the file. Quote Link to comment Share on other sites More sharing options...
bvc Posted May 20, 2003 Report Share Posted May 20, 2003 Having heard of a program, and using this_google_search I found a reference to it at this link; http://www.leuf.net/cgi/wikidn?WikiWaySources search the page for fromdos. It's about halfway down. There's also dos2unix if you read on. Quote Link to comment Share on other sites More sharing options...
bvc Posted May 20, 2003 Report Share Posted May 20, 2003 BTW, I think dos2unix is on the CD's. I've seen it several times somewhere? A urpmf dos will tell you. :wink: Quote Link to comment Share on other sites More sharing options...
tvlad Posted May 20, 2003 Author Report Share Posted May 20, 2003 Thx Bvc, though i'm wandering, couldn't it be done with awk, sed or some other very common tools ???? Quote Link to comment Share on other sites More sharing options...
bvc Posted May 20, 2003 Report Share Posted May 20, 2003 I think the page gave an example, and a perl script. I'm sure there is with common tools but that's not my area....it's aru's. :P He'll figure it out. Like the rest of us, aru hates to be defeated :wink: Quote Link to comment Share on other sites More sharing options...
aru Posted May 20, 2003 Report Share Posted May 20, 2003 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' Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.