Search code examples
pythonbashshellargparse

How to pass an argument to a shell script?


I have a shell script that points to a Python script.

script.sh

#!/bin/bash
python /folder/script.py

The Python script takes an argument, for example script.py -d 20210107

I tried running the shell script with the date parameter like script.sh -d 20210107 but this is not working. Do I need to add something to my shell script to fix this?


Solution

  • #!/bin/bash
    python /folder/script.py "$@"
    

    Pass arguments from upper script to lower script with $@.