介紹如何在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.