Sed教程(一)之安装配置

介绍如何在GNU/ Linux系统中设置sed环境html

安装使用软件包管理器

通常状况下,sed默认提供在大多数的GNU/ Linux发行版。使用该命令,以肯定其是否存在于您的系统上。若是没有,那么在基于Debian GNU/ Linux能够使用apt包管理器,以下所示安装sed:redis

[root]# sudo apt-get install sed 

安装后,确保sed能够经过命令行访问。工具

[root]# sed --versio

执行上面的代码,会获得以下结果:测试

sed (GNU sed) 4.2.2 
Copyright (C) 2012 Free Software Foundation, Inc. 
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.htmll>. 
This is free software: you are free to change and redistribute it. 
There is NO WARRANTY, to the extent permitted by law.  
Written by Jay Fenlason, Tom Lord, Ken Pizzini, 
and Paolo Bonzini. 
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-sed@gnu.org>. 
Be sure to include the word "sed" somewhere in the "Subject:" field.

一样,基于GNU/Linux的RPM安装sed,用yum包管理器,以下所示:spa

[root]# yum -y install sed

安装后,确保 sed 能够经过命令行访问。命令行

[root]# sed --version

执行上面的代码,会获得以下结果:htm

GNU sed version 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.

从源代码安装

因为GNU sed是GNU计划的一部分,它的源代码均可以避免费下载。咱们已经看到了如何使用软件包管理器安装sed。如今,了解如何从源代码安装sed。get

下面安装适用于任何的GNU/Linux软件,和大多数其余可自由使用的程序。下面是安装步骤:it

第1步 - 从一个真实的地方下载的源代码。命令行实用程序wget服务于这个目的。io

[root]# wget ftp://ftp.gnu.org/gnu/sed/sed-4.2.2.tar.bz2

第2步 - 解压缩和解压下载的源代码。

[root]# tar xvf sed-4.2.2.tar.bz2 

第3步 - 更改进入目录并运行配置。

[root]# ./configure 

第4步 - 一旦成功完成,配置生成Makefile文件。编译源代码,使用 make命令。

[root]# make

第5步 - 能够运行测试套件,以确保构建是干净的。这是一个可选步骤。

[root]# make check 

第6步 - 最后,安装sed实用工具。请确保有超级用户的权限。

[root]# sudo make install 

咱们已经成功编译并安装sed。经过执行 sed 命令,做以下验证:

[root]# sed --version

执行上面的代码,会获得以下结果:

sed (GNU sed) 4.2.2 
Copyright (C) 2012 Free Software Foundation, Inc. 
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.htmll>. 
This is free software: you are free to change and redistribute it. 
There is NO WARRANTY, to the extent permitted by law.  
Written by Jay Fenlason, Tom Lord, Ken Pizzini, 
and Paolo Bonzini. 
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-sed@gnu.org>. 
Be sure to include the word "sed" somewhere in the "Subject:" field.
相关文章
相关标签/搜索