Stream Editor - Lingkungan

Bab ini menjelaskan cara mengatur lingkungan SED pada sistem GNU / Linux Anda.

Instalasi Menggunakan Package Manager

Umumnya, SED tersedia secara default di sebagian besar distribusi GNU / Linux. Menggunakanwhichperintah untuk mengidentifikasi apakah itu ada di sistem Anda atau tidak. Jika tidak, maka instal SED pada GNU / Linux berbasis Debian menggunakanapt manajer paket sebagai berikut:

[jerry]$ sudo apt-get install sed

Setelah penginstalan, pastikan SED dapat diakses melalui baris perintah.

[jerry]$ sed --version

Saat menjalankan kode di atas, Anda mendapatkan hasil sebagai berikut:

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. 
         
        
       
      

Similarly, to install SED on RPM based GNU/Linux, use yum package manager as follows:

[root]# yum -y install sed

After installation, ensure that SED is accessible via command line.

[root]# sed --version

On executing the above code, you get the following result:

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. 
        
       
      

Installation from Source Code

As GNU SED is a part of the GNU project, its source code is available for free download. We have already seen how to install SED using package manager. Let us now understand how to install SED from its source code.

The following installation is applicable to any GNU/Linux software, and for most other freely-available programs as well. Here are the installation steps:

  • Download the source code from an authentic place. The command-line utility wget serves this purpose.

  • [jerry]$ wget ftp://ftp.gnu.org/gnu/sed/sed-4.2.2.tar.bz2
    
  • Decompress and extract the downloaded source code.

  • [jerry]$ tar xvf sed-4.2.2.tar.bz2 
    
  • Change into the directory and run configure.

  • [jerry]$ ./configure 
    
  • Upon successful completion, the configure generates Makefile. To compile the source code, issue a make command.

  • [jerry]$ make
    
  • You can run the test suite to ensure the build is clean. This is an optional step.

  • [jerry]$ make check 
    
  • Finally, install the SED utility. Make sure you have superuser privileges.

  • [jerry]$ sudo make install 
    

That is it! You have successfully compiled and installed SED. Verify it by executing the sed command as follows:

[jerry]$ sed --version

On executing the above code, you get the following result:

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.