parameters

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

  1. Jeremy

    Jeremy Member

    Joined:
    Sep 5, 2013
    Messages:
    34
    Likes Received:
    20
    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

    Joined:
    Oct 30, 2013
    Messages:
    220
    Likes Received:
    62
    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

    Joined:
    Jan 28, 2014
    Messages:
    223
    Likes Received:
    49
    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