parameters

Discussion in 'Command Line' started by Jeremy, May 1, 2014.

  1. Jeremy

    Jeremy Member

    Messages:
    34
    Likes Received:
    18
    Trophy Points:
    8
    I am trying to learn Bash scripting. I can't get a handle on parameters... I want to determine if a string has been sent to my script. How would I start this?


    Thanks for the help.
  2. GrumpyOldMan

    GrumpyOldMan Active Member

    Messages:
    120
    Likes Received:
    41
    Trophy Points:
    28
    The bash man page has a section on parameters that should explain everything for you. Pay especial attention to the section on "Special Parameters"
  3. bashcommando

    bashcommando Active Member

    Messages:
    184
    Likes Received:
    40
    Trophy Points:
    28
    If you are familiar to batch %1 is the same as $1 on bash
    So if you run the command
    Code:
    ./test.sh this is a test
    The variables recorded would be:
    Code:
    $0=test.sh
    $1=this
    $2=is
    $3=a
    $4=test

Share This Page