• Usually, there are two types of variables
  • Variable naming
  • Fundamentals of Shell Programming




    Download 6,34 Mb.
    Pdf ko'rish
    bet170/203
    Sana10.01.2024
    Hajmi6,34 Mb.
    #134102
    1   ...   166   167   168   169   170   171   172   173   ...   203
    Bog'liq
    Linux This Book Includes 4 Manuscripts The Underground Bible

    Fundamentals of Shell Programming 
    The shell consists of a group of systematic instructions or commands. Let
    us go and learn about some of the basic components that comprise the shell
    language .
    Variables
    Variables are a piece of memory in the computer random access system that
    is used to store the data. As discussed before variables are the most
    important components of a programming language and it is often called
    while writing functions or templates. 
    Usually, there are two types of variables: 
    a) Local variables
    b) environmental variables
    Let us discuss the functionalities of these variables in detail along with few
    command-line examples.


    a) Local variables
    Local variables are the one can which can be used in a private or single
    environment that is these cannot be used in other shell scripts even with a
    reference. These types of variables are used in short shell scripts. 
    b) Global variables
    Global variables are also known as environmental variables. These
    variables differ from the first one because these can be used in any shell
    script with a reference. For using the global variables, you need to export
    them to the local shell script file.
    Variable naming
    Variables present in the shell language should follow some varied
    instructions while naming. Remember that shell in-built commands like exit
    cannot be used for the names of variables. 
    Here are the instructions that need to be followed for naming a variable: 
    a) In shell language, variables differ from the capital and small letters. 
    b) A variable name should never start with a number or special character.
    Doing this may give an error saying that the variable name cannot be
    initialized. 
    Here are some of the various examples that can be used 
    love
    dude
    ra344
    And here are some of the variable names that cannot be used
    1hjsd
    #feg e



    Download 6,34 Mb.
    1   ...   166   167   168   169   170   171   172   173   ...   203




    Download 6,34 Mb.
    Pdf ko'rish