[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[工具合集] sed 4.2.2 for Windows 单文件版

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

sed 4.0.7 http://pan.baidu.com/s/1bnF7mer
sed 4.1.4 http://pan.baidu.com/s/1AjBCM
sed 4.2.1 http://pan.baidu.com/s/1dD3XMxz
  1. What's New:
  2. Sed 4.2.2
  3. * don't misbehave (truncate input) for lines of length 2^31 and longer
  4. * fix endless loop on incomplete multibyte sequences
  5. * -u also does unbuffered input, rather than unbuffered output only
  6. * New command `F' to print current input file name
  7. * sed -i, s///w, and the `w' and `W' commands also obey the --binary option
  8.   (and create CR/LF-terminated files if the option is absent)
  9. * --posix fails for scripts (or fragments as passed to the -e option) that
  10.   end in a backslash, as they are not portable.
  11. * New option -z (--null-data) to separate lines by ASCII NUL characters.
  12. * \x26 (and similar escaped sequences) produces a literal & in the
  13.   replacement argument of the s/// command, rather than including the
  14.   matched text.
  15. ----------------------------------------------------------------------------
  16. Sed 4.2.1
  17. * fix parsing of s/[[[[[[[[[]//
  18. * security contexts are preserved by -i too under SELinux
  19. * temporary files for sed -i are not made group/world-readable until
  20.   they are complete
  21. ----------------------------------------------------------------------------
复制代码
--------------------------------------------------------------
有朋友反映说,这个sed在64bit系统下运行不成功。
其实这是由编译器决定的:
bin文件是在DJGPP环境下编译,DJGPP的GCC编译器生成32位保护模式的程序,用于MS-DOS系统居多。
CMD兼容DOS下的程序,所以编译出来的程序CMD也可以使用。

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

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

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

评分人数

    • gawk: 感谢分享技术 + 1
---学无止境---

收下备用了,多谢分享

TOP

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

TOP

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

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

我喜欢批处理之家

TOP

sed在gnuwin32里不就是4.2.1么...楼主这个貌似没有-c...
  1. $ sed --version
  2. GNU sed 版本 4.2.1
  3. Copyright (C) 2009 Free Software Foundation, Inc.
  4. This is free software; see the source for copying conditions.  There is NO
  5. warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
  6. to the extent permitted by law.
  7. GNU sed home page: <http://www.gnu.org/software/sed/>.
  8. General help using GNU software: <http://www.gnu.org/gethelp/>.
  9. E-mail bug reports to: <bug-gnu-utils@gnu.org>.
  10. Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.
  11. $ sed         
  12. 用法: sed.exe [选项]... {脚本(如果没有其他脚本)} [输入文件]...
  13.   -n, --quiet, --silent
  14.                  取消自动打印模式空间
  15.   -e 脚本, --expression=脚本
  16.                  添加“脚本”到程序的运行列表
  17.   -f 脚本文件, --file=脚本文件
  18.                  添加“脚本文件”到程序的运行列表
  19.   -i[扩展名], --in-place[=扩展名]
  20.                  直接修改文件(如果指定扩展名就备份文件)
  21.   -b, --binary
  22.                  以二进制方式打开文件 (回车加换行不做特殊处理)
  23.   -c, --copy
  24.                  use copy instead of rename when shuffling files in -i mode
  25.                  (avoids change of input file ownership)
  26.   -l N, --line-length=N
  27.                  指定“l”命令的换行期望长度
  28.   --posix
  29.                  关闭所有 GNU 扩展
  30.   -r, --regexp-extended
  31.                  在脚本中使用扩展正则表达式
  32.   -s, --separate
  33.                  将输入文件视为各个独立的文件而不是一个长的连续输入
  34.   -u, --unbuffered
  35.                  从输入文件读取最少的数据,更频繁的刷新输出
  36.       --help     打印帮助并退出
  37.       --version  输出版本信息并退出
  38. 如果没有 -e, --expression, -f 或 --file 选项,那么第一个非选项参数被视为
  39. sed脚本。其他非选项参数被视为输入文件,如果没有输入文件,那么程序将从标准
  40. 输入读取数据。
  41. GNU sed home page: <http://www.gnu.org/software/sed/>.
  42. General help using GNU software: <http://www.gnu.org/gethelp/>.
复制代码

TOP

回复 5# daols


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

TOP

回复 5# daols


    那个需要dll文件,不爽。

TOP

怎么编译的?

TOP

这个有什么用,求解释。

TOP

---学无止境---

TOP

回复 8# Demon


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

Cygwin:一个在windows平台上运行的unix模拟环境。编译出来的软件需要有库文件依赖。

MinGw:我觉得GnuWin32应该就是用的这个编译环境。因为安装出来的软件,库文件依赖就是用的这个环境里面的。不能单独编译出单文件版的。

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

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

我一直在找用MinGw编译单文件版的方法,但是找好久都没有找到适合的。有一次在一个德国的网站上看到Gawk,这个就编译的很好,应该不是DJGPP编译出来的,我也不清楚怎么编译的。发邮件去问了他,但是都没有得到有用的答案。感觉自己还是太菜了,很多东西都不懂,编译起来束手束脚。O_O
---学无止境---

TOP

回复  Demon


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

:一个在windows平台上运行的unix ...
broly 发表于 2012-6-5 19:11



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

TOP

回复 10# broly


    谢谢,先慢慢学学。

TOP

回复 12# Demon


    sed4.2.1我没有编译成功,附件那个是DJGPP官网上下载的。我只编译Gawk成功了(根据GNU给的官方文档)。GNU官方文档没有给出sed在DJGPP下编译的方法。
   所以我跑去DJGPP官网找到一个DJGPP环境的编译方法,但是也是编译不了,总是很多问题,一步步解决了,到了后面一步,找不到解决的方法了。
  
   编译文档,有兴趣可以试试:
  1. This is a port of GNU Sed 4.2.1 to MSDOS/DJGPP.
  2. 1.:     DJGPP specific changes.
  3.         =======================
  4.       - To compile the sources you will need libsupp 6.2 or later.  The library
  5.         provides a fixed version of popen()/pclose() functions and some other
  6.         functions from the libc cvs repository that will replace or extend the
  7.         functionality of those ones that come with djdev204 (2004-11-25).
  8.       - This version of the port will support the generation of 8+3 valid
  9.         backup names for input file names if only SFN support is available.
  10.         This concerns the '-i' option (in-place editing).
  11.       - The port will open the input stream in binary mode.  This will allow to
  12.         process files that contain embedded ^Z and lone ^M characters.
  13.       - This version of the port no longer support the bootstrapping of sed.
  14.       - You will need LFN support to configure and compile the source package.
  15.         I have no plans to support SFN systems to build the sed binaries.
  16.         As usual, all djgpp specific files (config.bat, diffs, readme files,
  17.         etc.) are located in the djgpp subdir.
  18. 2.:     Installing the binary package.
  19.         ==============================
  20. 2.1.:   Copy the binary distribution into the top DJGPP installation directory
  21.         and unzip it running *ONE* of the following commands:
  22.           unzip32 sed421b.zip      or
  23.           djtarx sed421b.zip       or
  24.           pkunzip -d sed421b.zip
  25. 2.2.:   If there is no entry for the sed info docs in your dir file, located
  26.         info directory, create one running the command:
  27.           install-info --info-dir=/dev/env/DJDIR/info /dev/env/DJDIR/info/sed.info
  28.         For futher information about GNU Sed please read the info docs and the NEWS file.
  29. 3.:     Building the binaries from sources.
  30.         ===================================
  31. 3.1.:   To build the binaries you will need the following binary packages:
  32.           djdev203.zip (patch level 2, see the djdev203.dsm)
  33.           bsh204br2.zip, gccNNNb.zip, bnuNNNb.zip, makNNNb.zip,
  34.           filNNNb.zip, shlNNNb.zip, txtNNNb.zip, txiNNNb.zip,
  35.           grepNNNb.zip, sedNNNb.zip and difNNNb.zip.
  36.         NNN stands for the current version of that port.  All these packages can
  37.         be found in the /v2gnu directory of ftp.delorie.com and any mirror.
  38.         Previuos versions of those packages may do the job as well but I have
  39.         not tested this.
  40. 3.2.:   Create a temporary directory. Copy the source package: sed421s.zip
  41.         into the directory and unzip it runnig ONE of the following commands:
  42.           unzip32 sed421s.zip      or
  43.           djtarx sed421s.zip       or
  44.           pkunzip -d sed421s.zip
  45. 3.3.:   If for some reason you want to reconfigure the package cd into the top
  46.         srcdir (sed-4.2-1) and run the following commands:
  47.           del djgpp\config.cache
  48.           make distclean
  49.           djgpp\config
  50.         Please note that you *MUST* delete the config.cache file in the /djgpp
  51.         subdir or you will not really reconfigure the sources because the
  52.         configuration informations will be read from the cache file instead
  53.         of being newly computed.
  54.         To build the programs in a directory other than where the sources are,
  55.         you must add the parameter that specifies the source directory,
  56.         e.g:
  57.           x:\src\gnu\sed-4.2-1\djgpp\config x:/src/gnu/sed-4.2-1
  58.         or:
  59.           x:\src\gnu\sed-4.2-1\djgpp\xp-config x:/src/gnu/sed-4.2-1
  60.         Lets assume you want to build the binaries in a directory placed on a
  61.         different drive (z:\build in this case) from where the sources are,
  62.         then you will run the following commands:
  63.           z:
  64.           md \build
  65.           cd \build
  66.           x:\src\gnu\sed-4.2-1\djgpp\config x:/src/gnu/sed-4.2-1
  67.         or:
  68.           x:\src\gnu\sed-4.2-1\djgpp\xp-config x:/src/gnu/sed-4.2-1
  69.         The order of the options and the srcdir option does not matter. You
  70.         *MUST* use forward slashes to specify the source directory.
  71.         The batch file will set same environment variables, make MSDOS specific
  72.         modifications to the Makefile.ins and supply all other needed options
  73.         to the configure script.
  74. 3.4.:   To compile the package run from the top srcdir the command:
  75.           make
  76. 3.5.:   Now you can run the tests if you like. From the top srcdir run the
  77.         command:
  78.           make check
  79.         No one of the tests should fail no matter if you have used stock djdev203
  80.         or beta djdev204.
  81. 3.6.:   To install the binary, info docs and man pages run the following command
  82.         from the top srcdir:
  83.           make install
  84.         This will install the products into your DJGPP installation tree given
  85.         by the default prefix "/dev/env/DJDIR". If you prefer to install them
  86.         into some other directory you will have to set prefix to the appropiate
  87.         value.
  88.         Example:
  89.           make install prefix=z:/some/other/dir
  90.         Send sed specific bug reports to <bonzini@gnu.org>.
  91.         Send suggestions and bug reports concerning the DJGPP port
  92.         to comp.os.msdos.djgpp or <djgpp@delorie.com>.
  93. Enjoy.
  94.           Guerrero, Juan Manuel <juan.guerrero@gmx.de>
复制代码
---学无止境---

TOP

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.

TOP

返回列表