This topic has been archived. It cannot be replied.
-
工作学习 / IT杂谈 / 今天反正没事情干,多问问,VI怎么去除文本文件没行最后的CTRL+m,一直没有想到好办法(这种文件是被WINDOWS编辑保存过后产生的)
-oceandeep(北极熊® Zzz Zzz);
2002-11-4
(#836650@0)
-
呵呵,我这个人比较懒,所以就用最简单的办法,windows编辑完了以后,ftp到unix的时候用ascii模式,尾巴上的Ctrl+M就自动过滤掉了。
-flying_snow(飞雪浮冰);
2002-11-4
(#836688@0)
-
我也没办法,被老板改过的东西就成这样了,我总不能去骂他吧,老这样气死我了
-oceandeep(北极熊® Zzz Zzz);
2002-11-4
(#836694@0)
-
那你自己重新ftp一下不就可以了?或者编一个小程序,无非是0x0d,0x0a字符的处理,很简单的。vi 可能也可以用替换字符的办法解决,不过我没有试过Ctrl+M是什么字符,呵呵 :-PP
-flying_snow(飞雪浮冰);
2002-11-4
(#836726@0)
-
VI替换控制字符好象不行(我搞不定),再传一遍,要到老板的电脑那里去,遍这种读字符的程序好象几百年前做过,现在都不知道怎么弄了,就想偷懒点用VI或者UNIX现成命令如SED也行啊
-oceandeep(北极熊® Zzz Zzz);
2002-11-4
(#836758@0)
-
在unix机器上自己ftp给自己试试看,ftp localhost,申明:我没有试过,你是过告诉我一声成不成?
-flying_snow(飞雪浮冰);
2002-11-4
(#836782@0)
-
看到你的建议,我都乐了,能怎么搞,高,有创造性,你真的很聪明(不是歪话),我怎么没想到,去试试,真的成功了,你就真的很牛了
-oceandeep(北极熊® Zzz Zzz);
2002-11-5
(#836792@0)
-
我倒是要试试uid的办法,他的要简单多了,如果成功,他更牛! :-))
-flying_snow(飞雪浮冰);
2002-11-5
(#836806@0)
-
大声急呼,为什么不用Utral Edit ?多好的tools啊
-uid(㊣Miracle);
2002-11-5
(#836807@0)
-
很久以前用过一次好象要注册,懒的去找了,你有没有不用注册的,我尝试一下
-oceandeep(北极熊® Zzz Zzz);
2002-11-5
(#836836@0)
-
估计在注册表里把它的键值都删了, 它就不问你要注册了
-uid(㊣Miracle);
2002-11-5
(#836847@0)
-
这么能干,又一高招,我赶明儿,把你们的高招,都去试试
-oceandeep(北极熊® Zzz Zzz);
2002-11-5
(#836864@0)
-
^M就是回车啊。你输入的时候按^M,就给你一个回车。
-pasu(InTheSky);
2002-11-5
(#836906@0)
-
Easy :-), 用utrl -edit 里的dos-to-unix convert就可以了, 也可以用unix下的dos2unix 的shell,也可以用vi创建一个新文件,用r命令把原文件读近来!wq保存即可。
-uid(㊣Miracle);
2002-11-4
(#836713@0)
-
看不太懂,前面要用工具就不用再说了,后面的东西是什么?谢谢
-oceandeep(北极熊® Zzz Zzz);
2002-11-4
(#836722@0)
-
就是用VI随便创建一个空文件,再用VI的r (read)命令把目标文件读近来,然后保存。新的文件则不包括那些ctrl的字符
-uid(㊣Miracle);
2002-11-4
(#836739@0)
-
真的? :r 读进来的文件不带CTRL+M,太谢谢你了,又学了一招
-oceandeep(北极熊® Zzz Zzz);
2002-11-4
(#836760@0)
-
不行。还是有。
-pasu(InTheSky);
2002-11-5
(#836890@0)
-
你在试,好,把这里所有的答案都试一遍,看看是不是都是正确答案
-oceandeep(北极熊® Zzz Zzz);
2002-11-5
(#836896@0)
-
只对VI里的解决方案有兴趣,呵呵。
-pasu(InTheSky);
2002-11-5
(#836907@0)
-
下面还有个答案呢
-oceandeep(北极熊® Zzz Zzz);
2002-11-5
(#836932@0)
-
请把您的文件发给我, 我明天去试。
-uid(㊣Miracle);
2002-11-5
(#836911@0)
-
没什么特别的。就是在windows里找一个有回车换行的text file,用bin方式ftp上unix。我想可能是我的做法不准确,你把你的详细步骤说说?
-pasu(InTheSky);
2002-11-5
(#836940@0)
-
I tried today, It still worked! (1)create txt file in w2k, ftp with <bin> file to server, and (2)vi newFile (3)r targetFil (4):wq save it (5) ftp <bin>back to w2k (6)open with notepad (7)View changes!,I guess when VI build a new file it read char from old file and add it's own line return and eof charaters.
I also verified the -flying_snow's ftp with ASCII mode, it also works!
-uid(㊣Miracle);
2002-11-5
{183}
(#838416@0)
-
no, the problem come from ftp instead of vi
-xiagangle(xiagangle);
2002-11-5
(#838433@0)
-
no, i verified, if you ftp bin-in and bin-out, then no changes, but if you bin-in, vi and bin-out, then you see the changes; ftp will change it when in ASCII mode, not BIN mode.
-uid(㊣Miracle);
2002-11-5
(#838435@0)
-
faint!!! 不晕不行。你这么倒腾来倒腾去,还是什么都没有动嘛。在windows上看当然没有问题啦!你在unix下看你的newFile试试? :pp
-pasu(InTheSky);
2002-11-5
(#838438@0)
-
Well, I have another example. (1)I wrote a sql script for db2 in w2k (2)ftp <bin>to unix (3)db2 -tvf my.sql (4) It report exception: End of file reached!, BUT, I created a empty file and read my.sql in,and run the same command db2 -tvf myAnother.sql , it works! So this proved when Vi read the file in, actually it recreate the file and replace eof and eol for you. *_*
-uid(㊣Miracle);
2002-11-5
{167}
(#838477@0)
-
BTW, the purpose to ftp it back is just let you see the changes. It'll remove eol for you. Normally, it one-way direction. You don't want use it in w2k ,right?
-uid(㊣Miracle);
2002-11-5
(#838499@0)
-
no way, see#838416
-uid(㊣Miracle);
2002-11-5
(#838419@0)
-
r 命令可以解决?文件读进来的时候会过滤字符吗?倒是值得一试。
-flying_snow(飞雪浮冰);
2002-11-4
(#836745@0)
-
是过滤掉那些windows的回车和文件结束符, 嘿嘿, 俺一直这样用着...
-uid(㊣Miracle);
2002-11-4
(#836770@0)
-
好好,实在是高,我以后也用这招! :-DD
-flying_snow(飞雪浮冰);
2002-11-5
(#836790@0)
-
s/^H<Enter>//g
-noexit(书中自有▲老太婆);
2002-11-5
(#836805@0)
-
这个是我一直想用的命令,明天一定要试试
-flying_snow(飞雪浮冰);
2002-11-5
(#836821@0)
-
s/^V<Enter>//g
-noexit(书中自有▲老太婆);
2002-11-5
(#836934@0)
-
意思是CTRL+H改成CTRL+V,然后在ENTER?
-oceandeep(北极熊® Zzz Zzz);
2002-11-5
(#836951@0)
-
看不懂,你这里面的ENTER是真ENTER还是解释意思?而且^H代表的意思在VI里面根本不等于CTRL+H,虽然表面看来一模一样
-oceandeep(北极熊® Zzz Zzz);
2002-11-5
(#836840@0)
-
holding <Ctl> and press H, release <Ctl>, then press <Enter> key. you'll get ^M on command line.
-noexit(书中自有▲老太婆);
2002-11-5
(#836861@0)
-
真的?又一个高手出现了,你意思是CTRL+H打头然后键入ENTER,这样VI的命令行就不会认为是命令结束,而是认为是字符,然后替换掉,好,又一种途径。谢谢
-oceandeep(北极熊® Zzz Zzz);
2002-11-5
(#836871@0)
-
再多罗嗦一句吧:这和vi本身无关,是vi的字符终端(如vt100、ansi等)的支持。
-noexit(书中自有▲老太婆);
2002-11-5
(#836886@0)
-
跟VI有关,看我下面的贴。
-pasu(InTheSky);
2002-11-5
(#836946@0)
-
sorry. should be ^V. ^H itself == <Backspace>. I didn't think it over.
-noexit(书中自有▲老太婆);
2002-11-5
(#836927@0)
-
还不太懂,什么东西等于BACKSPACE?BACKSPACE和这个有什么关系?
-oceandeep(北极熊® Zzz Zzz);
2002-11-5
(#836937@0)
-
没关系。他记错了,呵呵。
-pasu(InTheSky);
2002-11-5
(#836944@0)
-
不行。你用什么shell?什么TERM?
-pasu(InTheSky);
2002-11-5
(#836894@0)
-
s/^V<Enter>//g
-noexit(书中自有▲老太婆);
2002-11-5
(#836915@0)
-
COOL!拜谢。^V In input mode, ^V quotes the next character to permit
the insertion of special characters (including ESC)
into the file.
先前一直没想起来这个universal quoter是谁,呵呵。看了你的提示在man里找着了。
-pasu(InTheSky);
2002-11-5
{257}
(#836935@0)
-
哦,懂了,CTRL+v表示后面是特殊字符,谢谢NOEXIT,孔子说的果然不错,3人行,必有我师,这么小个问题,有这么多的答案
-oceandeep(北极熊® Zzz Zzz);
2002-11-5
(#836956@0)
-
你上当了孔子其实无非是想其他两个人都交学费给他嘛,哈哈。
-pasu(InTheSky);
2002-11-5
{48}
(#836967@0)
-
巨谢!
-flying_snow(飞雪浮冰);
2002-11-5
(#836969@0)
-
没点新意啊你 :pp
-pasu(InTheSky);
2002-11-5
(#836987@0)
-
本人的苯办法, FTP到LOCAL, 用WORDPAD或WORD打开, 然后COPY-PASTE到UNIX的cat > filename.txt下.
-gitar(lala);
2002-11-5
(#836808@0)
-
你是用了编辑器了吧,这也是个办法
-oceandeep(北极熊® Zzz Zzz);
2002-11-5
(#836846@0)
-
看了楼上高手的解决方案,想把俺说的收回来. 真是苯办法呀. 小声问一句: 干嘛要用VI? EMACS不好吗?
-gitar(lala);
2002-11-5
(#836905@0)
-
没用过你的EMACS,不知道是什么好东西?只知道还有一个编辑器叫ED,但也几乎没有用过
-oceandeep(北极熊® Zzz Zzz);
2002-11-5
(#837075@0)
-
对不起,我以为EMACS和VI一样通用呐. 免费, UNIX, LINUX, WIN都可用, 有edit, compile, debug功能, 但我只会EDIT.
-gitar(lala);
2002-11-5
(#837184@0)
-
g/.$/s//g这是VI下的字符替换命令
-e_dragon(e_dragon);
2002-11-5
(#837275@0)
-
:%s/special1special2//gthe true solution, in vi use the following command:
press ESC key first to enter command status
:%s/special1special2//g
note:
1.special1 stands for ^V(presss CTRL and V together)
2.special2 stands for ^M(press CTRL and M together)
3.no space between special1 and special2
-harvshen(harv);
2002-11-5
{279}
(#837470@0)
-
====See Above Solution, p.s. press Enter after key in the command ====
-harvshen(harv);
2002-11-5
(#837481@0)
-
按ESC键,:1,$ s/^V^M//g, 再回车即可,其中^V是压住CTRL再按V,^M也是压住CTRL再按M,这事我以前常干。
-mickeymouse(米老鼠);
2002-11-5
(#837491@0)
-
dos2unix, both solaris and scounix have such command, I don't others
-johnnyzh(bubble);
2002-11-5
(#837619@0)
-
:1,$ s/.$//gIt won't happen if you don't copy ASCII files from Windows to UNIX. Try Samba and save your files on UNIX directly.
-shu(shu);
2002-11-5
{117}
(#838368@0)
-
:set format=unix<cr>
-gettext(gettext);
2002-11-5
(#838527@0)