批处理之家's Archiver

broly 发表于 2012-5-27 13:59

sed 4.2.2 for Windows 单文件版

Sed-4.2.2-bin.zip:
[url]http://pan.baidu.com/s/1pJkDALt[/url]
[url]http://code.google.com/p/gnu-on-windows/downloads/list[/url]

sed 4.0.7 [url]http://pan.baidu.com/s/1bnF7mer[/url]
sed 4.1.4 [url]http://pan.baidu.com/s/1AjBCM[/url]
sed 4.2.1 [url]http://pan.baidu.com/s/1dD3XMxz[/url][code]What's New:
Sed 4.2.2

* don't misbehave (truncate input) for lines of length 2^31 and longer

* fix endless loop on incomplete multibyte sequences

* -u also does unbuffered input, rather than unbuffered output only

* New command `F' to print current input file name

* sed -i, s///w, and the `w' and `W' commands also obey the --binary option
  (and create CR/LF-terminated files if the option is absent)

* --posix fails for scripts (or fragments as passed to the -e option) that
  end in a backslash, as they are not portable.

* New option -z (--null-data) to separate lines by ASCII NUL characters.

* \x26 (and similar escaped sequences) produces a literal & in the
  replacement argument of the s/// command, rather than including the
  matched text.

----------------------------------------------------------------------------
Sed 4.2.1

* fix parsing of s/[[[[[[[[[]//

* security contexts are preserved by -i too under SELinux

* temporary files for sed -i are not made group/world-readable until
  they are complete

----------------------------------------------------------------------------[/code]--------------------------------------------------------------
有朋友反映说,这个sed在64bit系统下运行不成功。
其实这是由编译器决定的:
bin文件是在[url=http://www.delorie.com/djgpp/]DJGPP[/url]环境下编译,DJGPP的GCC编译器生成32位保护模式的程序,用于MS-DOS系统居多。
CMD兼容DOS下的程序,所以编译出来的程序CMD也可以使用。

但是DJGPP编译的程序貌似不支持64位系统(没有深入了解,我也不敢肯定。),所以我用另外一个编译环境(MinGW)重新编译了sed。
这次这个可以兼容64bit了。我只是大概测试了此sed,也不知道以后有没有BUG出现,所以希望发现BUG的朋友可以反馈一下。

sed4.2.1.zip
[url=http://pan.baidu.com/share/link?shareid=268446709&uk=1124163200]http://pan.baidu.com/share/link?shareid=268446709&uk=1124163200[/url]

[new]sed-4.2.1-bin.zip
[URL=http://pan.baidu.com/share/link?shareid=270499557&uk=1124163200]http://pan.baidu.com/share/link?shareid=270499557&uk=1124163200[/URL]

clonecd 发表于 2012-5-28 08:27

收下备用了,多谢分享

gawk 发表于 2012-5-28 13:42

经测试,使用-i选项的时候,不会在当前目录产生多余的临时文件,很好,感谢分享。

gawk 发表于 2012-5-28 13:45

再次测试,在CMD中处理中文时不会出现早期版本的乱码现象,不错。

[quote]C:\Test>sed "s/批处理/我喜欢&/g" a.txt

我喜欢批处理之家[/quote]

daols 发表于 2012-5-28 18:55

sed在gnuwin32里不就是4.2.1么...楼主这个貌似没有-c...[code]$ sed --version
GNU sed 版本 4.2.1
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
to the extent permitted by law.

GNU sed home page: <http://www.gnu.org/software/sed/>.
General help using GNU software: <http://www.gnu.org/gethelp/>.
E-mail bug reports to: <bug-gnu-utils@gnu.org>.
Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.

$ sed         
用法: sed.exe [选项]... {脚本(如果没有其他脚本)} [输入文件]...

  -n, --quiet, --silent
                 取消自动打印模式空间
  -e 脚本, --expression=脚本
                 添加“脚本”到程序的运行列表
  -f 脚本文件, --file=脚本文件
                 添加“脚本文件”到程序的运行列表
  -i[扩展名], --in-place[=扩展名]
                 直接修改文件(如果指定扩展名就备份文件)
  -b, --binary
                 以二进制方式打开文件 (回车加换行不做特殊处理)
  -c, --copy
                 use copy instead of rename when shuffling files in -i mode
                 (avoids change of input file ownership)
  -l N, --line-length=N
                 指定“l”命令的换行期望长度
  --posix
                 关闭所有 GNU 扩展
  -r, --regexp-extended
                 在脚本中使用扩展正则表达式
  -s, --separate
                 将输入文件视为各个独立的文件而不是一个长的连续输入
  -u, --unbuffered
                 从输入文件读取最少的数据,更频繁的刷新输出
      --help     打印帮助并退出
      --version  输出版本信息并退出

如果没有 -e, --expression, -f 或 --file 选项,那么第一个非选项参数被视为
sed脚本。其他非选项参数被视为输入文件,如果没有输入文件,那么程序将从标准
输入读取数据。
GNU sed home page: <http://www.gnu.org/software/sed/>.
General help using GNU software: <http://www.gnu.org/gethelp/>.[/code]

broly 发表于 2012-5-29 13:42

[b]回复 [url=http://www.bathome.net/redirect.php?goto=findpost&pid=109287&ptid=16975]5#[/url] [i]daols[/i] [/b]


    Gnuwin32里面是要安装的,而且还附带一些库文件。这个只是个单文件版。
    在GNU官网给出的源码中,并没有-c这个选项吧?估计是Gnuwin32自己加上去的。

gawk 发表于 2012-5-29 21:57

[b]回复 [url=http://www.bathome.net/redirect.php?goto=findpost&pid=109287&ptid=16975]5#[/url] [i]daols[/i] [/b]


    那个需要dll文件,不爽。

Demon 发表于 2012-6-5 10:57

怎么编译的?

喃喃努努 发表于 2012-6-5 11:07

这个有什么用,求解释。

broly 发表于 2012-6-5 18:37

[b]回复 [url=http://www.bathome.net/redirect.php?goto=findpost&pid=110035&ptid=16975]9#[/url] [i]喃喃努努[/i] [/b]


    [url]http://www.bathome.net/thread-13203-1-1.html[/url]

broly 发表于 2012-6-5 19:11

[b]回复 [url=http://www.bathome.net/redirect.php?goto=findpost&pid=110033&ptid=16975]8#[/url] [i]Demon[/i] [/b]


    win32下编译GNU软件一般有3种比较常用的方法:

[url=http://www.cygwin.com/]Cygwin[/url]:一个在windows平台上运行的unix模拟环境。编译出来的软件需要有库文件依赖。

[url=http://www.mingw.org]MinGw[/url]:我觉得[url=http://gnuwin32.sourceforge.net]GnuWin32[/url]应该就是用的这个编译环境。因为安装出来的软件,库文件依赖就是用的这个环境里面的。不能单独编译出单文件版的。

[url=http://www.delorie.com/djgpp]DJGPP[/url]:DJGPP是GCC编译器在DOS操作系统上的一个移植版本,可以用来在DOS操作系统下编译生成32位保护模式的程序。其实这个就是编译在DOS系统下使用的。在windows的CMD下也可以兼容使用。

以上三种方法,我都有试过,都各有优缺点。
Cygwin这个缺点就是库文件的依赖,个人不喜欢。同样的,MinGw编译出来的也要库文件依赖的。
DJGPP就好一点,不会出现库文件依赖,可以编译出单文件版的,而且编译速度比前两个都要快,其缺点就是,字符兼容性没那么好。由于主要是面向DOS使用的,DOS字符集没有CMD下的丰富(DJGPP的编译器考虑的是英文版的系统),所以在使用编译出来的GNU软件后,CMD界面的中文字符无法识别,变成"???"。这一点就比较不好。

我一直在找用MinGw编译单文件版的方法,但是找好久都没有找到适合的。有一次在一个[url=http://www.bathome.net/redirect.php?goto=findpost&ptid=16755&pid=108484&fromuid=25503]德国的网站[/url]上看到Gawk,这个就编译的很好,应该不是DJGPP编译出来的,我也不清楚怎么编译的。发邮件去问了他,但是都没有得到有用的答案。感觉自己还是太菜了,很多东西都不懂,编译起来束手束脚。O_O

Demon 发表于 2012-6-5 20:04

[quote]回复  Demon


    win32下编译GNU软件一般有3种比较常用的方法:

:一个在windows平台上运行的unix ...
[size=2][color=#999999]broly 发表于 2012-6-5 19:11[/color] [url=http://bbs.bathome.net/redirect.php?goto=findpost&pid=110084&ptid=16975][img]http://bbs.bathome.net/images/common/back.gif[/img][/url][/size][/quote]


    附件里的那个是怎么编译的?

喃喃努努 发表于 2012-6-5 22:54

[b]回复 [url=http://www.bathome.net/redirect.php?goto=findpost&pid=110081&ptid=16975]10#[/url] [i]broly[/i] [/b]


    谢谢,先慢慢学学。

broly 发表于 2012-6-5 23:46

[b]回复 [url=http://www.bathome.net/redirect.php?goto=findpost&pid=110088&ptid=16975]12#[/url] [i]Demon[/i] [/b]


    sed4.2.1我没有编译成功,附件那个是DJGPP官网上下载的。我只编译Gawk成功了(根据GNU给的官方文档)。GNU官方文档没有给出sed在DJGPP下编译的方法。
   所以我跑去DJGPP官网找到一个DJGPP环境的编译方法,但是也是编译不了,总是很多问题,一步步解决了,到了后面一步,找不到解决的方法了。
  
   编译文档,有兴趣可以试试:[code]This is a port of GNU Sed 4.2.1 to MSDOS/DJGPP.

1.:     DJGPP specific changes.
        =======================

      - To compile the sources you will need libsupp 6.2 or later.  The library
        provides a fixed version of popen()/pclose() functions and some other
        functions from the libc cvs repository that will replace or extend the
        functionality of those ones that come with djdev204 (2004-11-25).
      - This version of the port will support the generation of 8+3 valid
        backup names for input file names if only SFN support is available.
        This concerns the '-i' option (in-place editing).
      - The port will open the input stream in binary mode.  This will allow to
        process files that contain embedded ^Z and lone ^M characters.
      - This version of the port no longer support the bootstrapping of sed.
      - You will need LFN support to configure and compile the source package.
        I have no plans to support SFN systems to build the sed binaries.

        As usual, all djgpp specific files (config.bat, diffs, readme files,
        etc.) are located in the djgpp subdir.


2.:     Installing the binary package.
        ==============================

2.1.:   Copy the binary distribution into the top DJGPP installation directory
        and unzip it running *ONE* of the following commands:
          unzip32 sed421b.zip      or
          djtarx sed421b.zip       or
          pkunzip -d sed421b.zip

2.2.:   If there is no entry for the sed info docs in your dir file, located
        info directory, create one running the command:
          install-info --info-dir=/dev/env/DJDIR/info /dev/env/DJDIR/info/sed.info

        For futher information about GNU Sed please read the info docs and the NEWS file.


3.:     Building the binaries from sources.
        ===================================

3.1.:   To build the binaries you will need the following binary packages:
          djdev203.zip (patch level 2, see the djdev203.dsm)
          bsh204br2.zip, gccNNNb.zip, bnuNNNb.zip, makNNNb.zip,
          filNNNb.zip, shlNNNb.zip, txtNNNb.zip, txiNNNb.zip,
          grepNNNb.zip, sedNNNb.zip and difNNNb.zip.
        NNN stands for the current version of that port.  All these packages can
        be found in the /v2gnu directory of ftp.delorie.com and any mirror.
        Previuos versions of those packages may do the job as well but I have
        not tested this.

3.2.:   Create a temporary directory. Copy the source package: sed421s.zip
        into the directory and unzip it runnig ONE of the following commands:
          unzip32 sed421s.zip      or
          djtarx sed421s.zip       or
          pkunzip -d sed421s.zip

3.3.:   If for some reason you want to reconfigure the package cd into the top
        srcdir (sed-4.2-1) and run the following commands:
          del djgpp\config.cache
          make distclean
          djgpp\config

        Please note that you *MUST* delete the config.cache file in the /djgpp
        subdir or you will not really reconfigure the sources because the
        configuration informations will be read from the cache file instead
        of being newly computed.
        To build the programs in a directory other than where the sources are,
        you must add the parameter that specifies the source directory,
        e.g:
          x:\src\gnu\sed-4.2-1\djgpp\config x:/src/gnu/sed-4.2-1
        or:
          x:\src\gnu\sed-4.2-1\djgpp\xp-config x:/src/gnu/sed-4.2-1

        Lets assume you want to build the binaries in a directory placed on a
        different drive (z:\build in this case) from where the sources are,
        then you will run the following commands:
          z:
          md \build
          cd \build
          x:\src\gnu\sed-4.2-1\djgpp\config x:/src/gnu/sed-4.2-1
        or:
          x:\src\gnu\sed-4.2-1\djgpp\xp-config x:/src/gnu/sed-4.2-1

        The order of the options and the srcdir option does not matter. You
        *MUST* use forward slashes to specify the source directory.

        The batch file will set same environment variables, make MSDOS specific
        modifications to the Makefile.ins and supply all other needed options
        to the configure script.


3.4.:   To compile the package run from the top srcdir the command:
          make

3.5.:   Now you can run the tests if you like. From the top srcdir run the
        command:
          make check

        No one of the tests should fail no matter if you have used stock djdev203
        or beta djdev204.

3.6.:   To install the binary, info docs and man pages run the following command
        from the top srcdir:
          make install

        This will install the products into your DJGPP installation tree given
        by the default prefix "/dev/env/DJDIR". If you prefer to install them
        into some other directory you will have to set prefix to the appropiate
        value.
        Example:
          make install prefix=z:/some/other/dir




        Send sed specific bug reports to <bonzini@gnu.org>.
        Send suggestions and bug reports concerning the DJGPP port
        to comp.os.msdos.djgpp or <djgpp@delorie.com>.

Enjoy.

          Guerrero, Juan Manuel <juan.guerrero@gmx.de>
[/code]

forfiles 发表于 2012-10-27 12:11

64位的Win7系统无法使用,是不是只能用32位的系统?

This version of e:\Test\sed.exe is not compatible with the version of Window
s you're running. Check your computer's system information to see whether you ne
ed a x86 (32-bit) or x64 (64-bit) version of the program, and then contact the s
oftware publisher.

tor524e 发表于 2012-10-28 16:50

这个是16位的..... 运行后会自动换成短目录模式(xp sp3)....

broly 发表于 2012-10-28 16:51

[b]回复 [url=http://www.bathome.net/redirect.php?goto=findpost&pid=119285&ptid=16975]15#[/url] [i]forfiles[/i] [/b]


    应该是。我找个时间试试编译一个64bit的。

forfiles 发表于 2012-10-28 19:46

[b]回复 [url=http://www.bathome.net/redirect.php?goto=findpost&pid=119338&ptid=16975]17#[/url] [i]broly[/i] [/b]


    如果能像那个多文件版的同时兼容32和64就好了

CrLf 发表于 2012-10-28 19:50

[b]回复 [url=http://bbs.bathome.net/redirect.php?goto=findpost&pid=119337&ptid=16975]16#[/url] [i]tor524e[/i] [/b]


    不知道为什么会调用 ntvdm 来模拟 16 位环境,我下载的 4.14 单文件版好像也是这样,但 4.2 多文件版却不会,是否是单文件版都会调用 ntvdm 呢?

tor524e 发表于 2012-10-28 20:12

[b]回复 [url=http://www.bathome.net/redirect.php?goto=findpost&pid=119346&ptid=16975]19#[/url] [i]CrLf[/i] [/b]

92.5k 的 那个 4.0.7版不会吧, 就是换行符比较纠结, 用起来问题不大.

3dnowex 发表于 2012-10-28 21:03

android ndk 里面有个很好用的sed 4.2.1,单文件,x64也可以用的。

tor524e 发表于 2012-10-28 21:29

android ndk 的sed -i 参数不能用

tmplinshi 发表于 2012-11-21 18:04

感谢分享。

这个版本能够正确计算中文字符。很多版本都把 1 个中文计算为两个字符。

523066680 发表于 2012-12-27 00:07

虽不明,但觉厉!{:2_31:}

Batcher 发表于 2012-12-27 09:36

升级到4.2.2喽

C:\Test>sed --version
sed (GNU sed) 4.2.2

tmplinshi 发表于 2012-12-30 13:34

感谢!

pdang 发表于 2013-5-3 23:44

楼主辛苦了  64位操作系统下不能用昂

Batcher 发表于 2013-5-4 00:10

[b]回复 [url=http://www.bathome.net/redirect.php?goto=findpost&pid=130577&ptid=16975]27#[/url] [i]pdang[/i] [/b]


    顶楼的两个附件都不行吗?报错信息分别是什么?

lky216 发表于 2013-5-4 00:20

[b]回复 [url=http://www.bathome.net/redirect.php?goto=findpost&pid=130586&ptid=16975]28#[/url] [i]Batcher[/i] [/b]


    有IIS6 的
C:\Inetpub\AdminScripts\adsutil.vbs
这个文件的主题吗?不知道从何入手,我先摆渡骨骼吧。

pdang 发表于 2013-5-4 07:08

[b]回复 [url=http://bbs.bathome.net/redirect.php?goto=findpost&pid=130586&ptid=16975]28#[/url] [i]Batcher[/i] [/b]


    您好 第二个可以 我win8_64系统 非常感谢(自己把第二个附件忽略了)

页: [1] 2

Powered by Discuz! Archiver 7.2  © 2001-2009 Comsenz Inc.