0

I have a first script getting arguments like this :

while getopts "m:t:r:zsqhc:" opt 2>/dev/null
do
    case ${opt} in
    m) machine=${OPTARG,^^}
    ;;
    t) [...];;
    .
    .

And so on. As you can see, some arguments need a value (like a string or a number), and some other don't.

This script then calls two other scripts, which need the same arguments. I would like to know how to give those scripts the arguments.

Thanks in advance !

1 Answer 1

1

With Shift you can account for arguments with and without values

Save your arguments (or a subset) in a variable to pass them to your other scripts.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot. I did it this way : tmp="" while (( "$#" )); do tmp="$tmp $1" shift done echo $tmp It returned me a string with all the arguments in the order I gave to my test script. I'm sorry the comment doesn't want to get the return char.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.