Search code examples
bashshellbin

How to pass parameters to myscript.sh which I need to execute using '/bin/bash'


How to pass parameters to myscript.sh which I need to invoke using '/bin/bash' as below

/bin/bash -c myscript.sh


Solution

  • ./myscript.sh arg1 arg2 arg3
    

    or

    /bin/bash myscript.sh arg1 arg2 arg3
    

    (You don't need the -c option)

    and inside the script you can retrieve them by:

    var1=$1
    var2=$2