I have this function and I need it to reference multiple arguments from a function using GNU parallel.
foo () {
cd ${HOME}/sh/xxx/xxx/xxx/folder_with_scripts
bash -H $1 #replace with echo in test run {echo $1 is being echoed}
bash -H $2 #replace with echo in test run {echo $2 is being echoed}
}
export -f foo
parallel foo ::: *script.sh bash*.sh
folder_with_scripts content
$ ls
firstscript.sh
secondscript.sh
thirdscript.sh
bashhim.sh
bashscript.sh
bashher.sh
parallel foo
basically executes all scripts following *script.sh
inside by referencing it as an argument inside foo
. Which is $1
. What I'm trying to do is have it also execute bash*.sh*
which are inside folders_with_scripts
directory by using $2
.
According to man parallel
, the syntax is:
parallel [options] [command [arguments]] ( ::: arguments | :::: argfile(s) )
Since ::: arguments
is plural, I'm assuming this is very possible.
result
For convenience sake, I'm replacing bash
with echo
$ ./foo.sh
firstscript.sh is being echoed
secondscript.sh is being echoed
thirdscript.sh is being echoed
is being echoed
is being echoed
is being echoed
wanted result
firstscript.sh is being echoed
secondscript.sh is being echoed
thirdscript.sh is being echoed
bashhim.sh is being echoed
bashscript.sh is being echoed
bashher.sh is being echoed