sed 使用環(huán)境

本章介紹如何在GNU/Linux系統(tǒng)上設(shè)置SED環(huán)境。

從軟件包安裝

通常,大多數(shù)GNU/Linux發(fā)行版默認(rèn)都提供SED。使用哪個命令來確定系統(tǒng)中是否存在該命令。如果沒有,請使用 apt 軟件包管理器在基于Debian的GNU/Linux上安裝SED,如下所示:

$sudo apt-get install sed 

安裝后,請確保可通過命令行訪問SED。

$sed --version

執(zhí)行上述代碼后,您將得到以下輸出:

sed (GNU sed) 4.2.2 
Copyright (C) 2012 Free Software Foundation, Inc. 
License GPLv3+: GNU GPL version 3 or later . 
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: . 
General help using GNU software: . 
E-mail bug reports to: . 
Be sure to include the word "sed" somewhere in the "Subject:" field.

同樣,要在基于RPM的GNU/Linux上安裝SED,請使用yum軟件包管理器,如下所示:

[root]# yum -y install sed

安裝后,請確??赏ㄟ^命令行訪問SED。

[root]# sed --version

執(zhí)行上述代碼后,您將得到以下輸出:

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: . 
General help using GNU software: . 
E-mail bug reports to: . 
Be sure to include the word "sed" somewhere in the "Subject:" field.

從源代碼安裝

由于GNU SED是GNU項目的一部分,因此可以免費下載其源代碼。我們已經(jīng)了解了如何使用程序包管理器安裝SED。現(xiàn)在讓我們了解如何從源代碼安裝SED。

以下安裝適用于任何GNU/Linux軟件,以及大多數(shù)其他免費可用的程序。以下是安裝步驟:

  • 從真實位置下載源代碼。命令行實用程序 wget 用于此目的。

$wget ftp://ftp.gnu.org/gnu/sed/sed-4.2.2.tar.bz2
  • 解壓縮并提取下載的源代碼。

  • $tar xvf sed-4.2.2.tar.bz2 

    切換到目錄并運行configure。

    $./configure 

    成功完成后, configure 會生成Makefile。要編譯源代碼,請發(fā)出 make 命令。

    $make
  • 這是一個可選步驟。

  • $make check 
  • 最后,安裝SED實用程序。確保您具有超級用戶特權(quán)。

  • $sudo make install 

    通過執(zhí)行 sed 命令驗證它,如下所示:

    $sed --version

    執(zhí)行上述代碼后,您將得到以下輸出:

    sed (GNU sed) 4.2.2 
    Copyright (C) 2012 Free Software Foundation, Inc. 
    License GPLv3+: GNU GPL version 3 or later . 
    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: . 
    General help using GNU software: . 
    E-mail bug reports to: . 
    Be sure to include the word "sed" somewhere in the "Subject:" field.
    
    丰满人妻一级特黄a大片,午夜无码免费福利一级,欧美亚洲精品在线,国产婷婷成人久久Av免费高清