Board logo

标题: [文本处理] 如何用批处理删除一批文件中的特定字符 [打印本页]

作者: mylife21    时间: 2009-5-30 14:37     标题: 如何用批处理删除一批文件中的特定字符

X-Newsreader: rusnews v1.02
Lines: 50
[email=jaeger@buphy.bu.edu]jaeger@buphy.bu.edu[/email] (Gregg Jaeger) writes:
>In article <[email=11847@vice.ICO.TEK.COM]11847@vice.ICO.TEK.COM[/email]> [email=bobbe@vice.ICO.TEK.COM]bobbe@vice.ICO.TEK.COM[/email] (Robert
>Beauchaine) writes:
>>Bennett, Neil.  "How BCCI adapted the Koran rules of banking".  The
>>Times.  August 13, 1991.
>
> So, let's see. If some guy writes a piece with a title that implies
> something is the case then it must be so, is that it?
Gregg, you haven't provided even a title of an article to support *your*
contention.
>>  This is how you support a position if you intend to have anyone
>>  respect it, Gregg.  Any questions?  And I even managed to include
>>  the above reference with my head firmly engaged in my ass.  What's
>>  your excuse?
>
> This supports nothing. I have no reason to believe that this is
> piece is anything other than another anti-Islamic slander job.

请教:
        一文件夹中有一批文件 内容如上 可以用记事本打开 怎么删除每行开头的“>”字符(仅是开头的) 批处理怎么实现
作者: solone1020    时间: 2009-5-30 15:24

这个不会,帮你顶下,,。。。
作者: 随风    时间: 2009-5-31 02:47

gawk 版的硬是搞不出来,谁会?帖个代码出来?
  1. @sed ":c;s/^>//g;/^>/b c" a.txt>s.txt
复制代码
  1. @echo off
  2. (for /f "tokens=* delims=>" %%a in (a.txt) do echo,%%a)>s.txt
复制代码

[ 本帖最后由 随风 于 2009-5-31 02:54 编辑 ]
作者: Batcher    时间: 2009-5-31 03:20     标题: 回复 3楼 的帖子

sed还可以这样:
  1. sed -i "s/^>\{1,\}//g" a.txt
复制代码

作者: Batcher    时间: 2009-5-31 03:39     标题: 回复 3楼 的帖子

gawk版:
  1. gawk "{gsub(/^>+/,\"\",$0);print}" a.txt
复制代码

作者: mamoru    时间: 2009-6-18 05:23     标题: 回复 3楼 的帖子

如果要删除的字符是"有没有可能实现?
作者: Batcher    时间: 2009-6-18 12:44     标题: 回复 6楼 的帖子

能实现
你自己试试就知道了




欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2