0

I want to implement a bash script that acts the following way

./script_a.sh script_b.sh $arg1 $arg2 ...

./script_a.sh would invoke script_b.sh on $arg1 $arg2... $argn I don't know how many args there are beforehand. how can this be one?

1
  • 1
    is script_b.sh already implemented, or is this a fresh design? If it is, why would you want to do it this way? Commented Oct 30, 2014 at 7:08

2 Answers 2

4

Try this as a wrapper:

#!/bin/bash
"$@"
Sign up to request clarification or add additional context in comments.

Comments

0

The $@ contains the list of all arguments passed to the script.

For example consider:

-sh-3.2$ cat scripta
echo $@
"./$@"

-sh-3.2$ cat scriptb
echo hello world $@

-sh-3.2$ bash scripta scriptb 1 2 3 4
scriptb 1 2 3 4
hello world 1 2 3 4

"./$@" calls the script in the argument, scriptb with the remaining arguments 1 2 3 4

hello world 1 2 3 4 is obtained on running the second sript, scriptb

Comments

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.